has_dynamic_columns 0.0.2 → 0.0.3
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/version.rb +1 -1
- data/lib/has_dynamic_columns.rb +3 -0
- data/spec/has_dynamic_columns_spec.rb +9 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e4bad99fd8958013ac1466934d53fb8be417612
|
4
|
+
data.tar.gz: ecf7e132334c6eb87377cd9d3806759b897bf4db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a0a720d565dadab5182c517a970608d0319f546d38cff0e09f042bf4b1b29d9abb73c1efaa5ea59a777ef6b0bc3a86329ea84c633714c94a390a806a80de9e0
|
7
|
+
data.tar.gz: 03cb3fefc739982f2d041cac8205e92edad8d650ab236c39ffb044c52dad4c29d4d72e6d2dd39ce0a6fcea9ce143a53d55068230f4f9f9426da35ab7b28bfd18
|
data/lib/has_dynamic_columns.rb
CHANGED
@@ -101,6 +101,9 @@ module HasDynamicColumns
|
|
101
101
|
|
102
102
|
# Need to join on each of the keys we are performing where on
|
103
103
|
options.each { |key, value|
|
104
|
+
# Don't bother with empty values
|
105
|
+
next if value.to_s.empty?
|
106
|
+
|
104
107
|
column_table = HasDynamicColumns::DynamicColumn.arel_table.alias("dynamic_where_"+key.to_s)
|
105
108
|
column_datum_table = HasDynamicColumns::DynamicColumnDatum.arel_table.alias("dynamic_where_data_"+key.to_s)
|
106
109
|
|
@@ -59,6 +59,15 @@ describe HasDynamicColumns do
|
|
59
59
|
|
60
60
|
expect(a.customers.dynamic_where(a, { first_name: "Butch" }).length).to eq(1)
|
61
61
|
end
|
62
|
+
|
63
|
+
it 'should find me with blank value' do
|
64
|
+
c = customer
|
65
|
+
c.save
|
66
|
+
a = c.account
|
67
|
+
|
68
|
+
expect(a.customers.dynamic_where(a, { first_name: "Butch", last_name: "" }).length).to eq(1)
|
69
|
+
end
|
70
|
+
|
62
71
|
it 'should return fields as json' do
|
63
72
|
json = customer.as_json(:root => "customer")
|
64
73
|
|