has_dynamic_columns 0.3.9 → 0.3.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aaf5c0ace61bd2b3a0f1a5b41307fccf18622755
4
- data.tar.gz: 69966df3be6a085e55614cf12632173850810fd6
3
+ metadata.gz: 74028ad6d4dca1d298b275c0879f2a187f61d1b2
4
+ data.tar.gz: b61a64ab18943484ed06b9d8ca5a0337d89c52b0
5
5
  SHA512:
6
- metadata.gz: 9d3d6c5c41464cadf77a77e0a8c1f4dd0c357039e266975b73e1a56d655dba3f89614bba2f50da462576d1d795ccf6523378ee62cb4c72aecb88bd325446c598
7
- data.tar.gz: 4484e55679cc4c506af1b036bb3bace89e5179894c7c6cb1c3e6e577d32b4d9781119daafa413b1869b9638cf6f6beec9e8669be3ce0649f9afa7395dec247ae
6
+ metadata.gz: 0b2951e434458da40841c18c0393749b9b60e37950eb2439cb0a8e5fb15eefc0f6573a71ca5d691b6978047edf96b6a678af6213586ff15605046540bfd70391
7
+ data.tar.gz: 0386aa1168bf20c38ebe9869fee2054b0fd93528257972ade4362a49012f3df221abf666c4cbf0d90257df88aeca88e92fed775366178bfd10a72172be85ac0e
@@ -187,6 +187,9 @@ module HasDynamicColumns
187
187
  self.group_values += [Arel::Nodes::Group.new(table[:id])]
188
188
  end
189
189
 
190
+ self.where_dynamic_columns_values_reset
191
+ self.order_dynamic_columns_values_reset
192
+
190
193
  build_arel_without_dynamic_columns
191
194
  end
192
195
 
@@ -20,6 +20,9 @@ module HasDynamicColumns
20
20
  @where_dynamic_columns_values ||= []
21
21
  @where_dynamic_columns_values << values
22
22
  end
23
+ def where_dynamic_columns_values_reset
24
+ @where_dynamic_columns_values = []
25
+ end
23
26
 
24
27
  # Collect all order clauses
25
28
  def order_dynamic_columns_values
@@ -30,6 +33,9 @@ module HasDynamicColumns
30
33
  @order_dynamic_columns_values ||= []
31
34
  @order_dynamic_columns_values << values
32
35
  end
36
+ def order_dynamic_columns_values_reset
37
+ @order_dynamic_columns_values = []
38
+ end
33
39
  end
34
40
 
35
41
  base.instance_eval do
@@ -20,6 +20,9 @@ module HasDynamicColumns
20
20
  @values[:where_dynamic_columns_values] ||= []
21
21
  @values[:where_dynamic_columns_values] << values
22
22
  end
23
+ def where_dynamic_columns_values_reset
24
+ @values[:where_dynamic_columns_values] = []
25
+ end
23
26
 
24
27
  # Collect all order clauses
25
28
  def order_dynamic_columns_values
@@ -30,6 +33,9 @@ module HasDynamicColumns
30
33
  @values[:order_dynamic_columns_values] ||= []
31
34
  @values[:order_dynamic_columns_values] << values
32
35
  end
36
+ def order_dynamic_columns_values_reset
37
+ @values[:order_dynamic_columns_values] = []
38
+ end
33
39
  end
34
40
 
35
41
  base.instance_eval do
@@ -1,3 +1,3 @@
1
1
  module HasDynamicColumns
2
- VERSION = "0.3.9"
2
+ VERSION = "0.3.10"
3
3
  end
@@ -226,17 +226,33 @@ describe ::HasDynamicColumns::ActiveRecord::QueryMethods do
226
226
  expect(result).to eq([["1", "George", "Marshall"], ["1", "Butch", "Casidy"], ["2", "Butch", "Marshall"]])
227
227
  end
228
228
 
229
- it 'should filter and order by the same column properly and not throw ambiguous column name errors' do
229
+ it 'should filter and order by the same column properly and not throw ambiguous column name errors', :focus => true do
230
+ customer = Customer.new(:account => account, :name => "1")
231
+ customer.fields = {
232
+ "first_name" => "Carlos",
233
+ "last_name" => "Marshall",
234
+ "email" => "butch.marshall@unittest.com",
235
+ "trusted" => false,
236
+ "last_contacted" => DateTime.parse("2012-01-01 01:01:01"),
237
+ "total_purchases" => 10,
238
+ "tags" => [
239
+ "a", "b", "c"
240
+ ]
241
+ }
242
+ customer.save
243
+
230
244
  result = Customer
231
245
  .where
232
246
  .has_dynamic_columns(
233
- :first_name => "A"
247
+ :first_name => "Carlos"
234
248
  )
235
249
  .with_scope(account)
236
250
  .order
237
251
  .by_dynamic_columns(first_name: :desc)
238
252
  .with_scope(account)
239
253
  expect{ActiveRecord::Base.connection.select_all(result.to_sql)}.to_not raise_error
254
+
255
+ expect(result.all.length).to eq(1)
240
256
  end
241
257
 
242
258
  it 'should preserve order by multiple dynamic columns' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_dynamic_columns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Butch Marshall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-16 00:00:00.000000000 Z
11
+ date: 2015-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord