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 +4 -4
- data/lib/has_dynamic_columns/active_record/query_methods.rb +3 -0
- data/lib/has_dynamic_columns/active_record/v3/relation.rb +6 -0
- data/lib/has_dynamic_columns/active_record/v4/relation.rb +6 -0
- data/lib/has_dynamic_columns/version.rb +1 -1
- data/spec/has_dynamic_columns/active_record/query_methods_spec.rb +18 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74028ad6d4dca1d298b275c0879f2a187f61d1b2
|
4
|
+
data.tar.gz: b61a64ab18943484ed06b9d8ca5a0337d89c52b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b2951e434458da40841c18c0393749b9b60e37950eb2439cb0a8e5fb15eefc0f6573a71ca5d691b6978047edf96b6a678af6213586ff15605046540bfd70391
|
7
|
+
data.tar.gz: 0386aa1168bf20c38ebe9869fee2054b0fd93528257972ade4362a49012f3df221abf666c4cbf0d90257df88aeca88e92fed775366178bfd10a72172be85ac0e
|
@@ -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
|
@@ -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 => "
|
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.
|
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-
|
11
|
+
date: 2015-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|