like_query 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/like_query/model_extensions.rb +11 -10
- data/lib/like_query/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 218fe9ef241c396ed43d5a0daffe4fb69fceccf534b2b15b425eca0e56cd5f0d
|
4
|
+
data.tar.gz: a3a37469d41c7ec574868480691dd727c61a8908ad34816c23297775b830323c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 134b7f5d618b4828a973de21a34250bc16cae0cfe086819cd4927a99941e4ba6cde50b1c2883feb4a63cc413333234076b15f7dfa3e8cbc81878692e04028481
|
7
|
+
data.tar.gz: 19ed347cd40c60819bf56d7ffdf28e6c64b183367bb5e9f11282cf8fec89450a95df0e88b623f477c2eeacb4f2c66f5877dd224e91c0235eaf9806205b088a7c
|
@@ -13,7 +13,7 @@ module LikeQuery
|
|
13
13
|
raise "only one array can be given: Either schema as one array or as multiple args, not as array"
|
14
14
|
end
|
15
15
|
|
16
|
-
queries =
|
16
|
+
queries = []
|
17
17
|
associations = []
|
18
18
|
@like_query_schema = schema
|
19
19
|
|
@@ -21,15 +21,16 @@ module LikeQuery
|
|
21
21
|
|
22
22
|
f_str = format_string_element(s)
|
23
23
|
|
24
|
-
q =
|
24
|
+
q = []
|
25
25
|
|
26
26
|
(schema.first.is_a?(Array) ? schema.first : schema).each do |p|
|
27
27
|
dbg("• Iterate schema => #{p}")
|
28
28
|
enum_lab = enum_keys(p, s)
|
29
29
|
|
30
30
|
if enum_lab.present?
|
31
|
-
|
32
|
-
dbg(-> { " Query from enum => #{
|
31
|
+
_q = arel_table[p].in(enum_lab).to_sql
|
32
|
+
dbg(-> { " Query from enum => #{_q}" })
|
33
|
+
q.push(_q)
|
33
34
|
|
34
35
|
elsif p.is_a?(Hash)
|
35
36
|
p.each do |k, v|
|
@@ -39,13 +40,13 @@ module LikeQuery
|
|
39
40
|
if v.is_a?(Symbol) || v.is_a?(String)
|
40
41
|
_q = create_arel(v, f_str, assoc)
|
41
42
|
if _q.present?
|
42
|
-
q
|
43
|
+
q.push(_q.to_sql)
|
43
44
|
end
|
44
45
|
elsif v.is_a?(Array)
|
45
46
|
v.each do |_v|
|
46
47
|
_q = create_arel(_v, f_str, assoc)
|
47
48
|
if _q.present?
|
48
|
-
q
|
49
|
+
q.push(_q.to_sql)
|
49
50
|
end
|
50
51
|
end
|
51
52
|
else
|
@@ -56,21 +57,21 @@ module LikeQuery
|
|
56
57
|
else
|
57
58
|
_q = create_arel(p, f_str)
|
58
59
|
if _q.present?
|
59
|
-
q
|
60
|
+
q.push(_q.to_sql)
|
60
61
|
end
|
61
62
|
|
62
63
|
end
|
63
64
|
|
64
65
|
end
|
65
|
-
queries
|
66
|
+
queries.push("(#{q.join(' OR ')})")
|
66
67
|
end
|
67
68
|
|
68
69
|
if associations.present?
|
69
|
-
r = left_outer_joins(associations).where(queries)
|
70
|
+
r = left_outer_joins(associations).where(queries.join(" AND "))
|
70
71
|
dbg(->{"RESULT => #{r.to_sql}"})
|
71
72
|
r
|
72
73
|
else
|
73
|
-
r = where(queries)
|
74
|
+
r = where(queries.join(" AND "))
|
74
75
|
dbg(->{"RESULT => #{r.to_sql}"})
|
75
76
|
r
|
76
77
|
end
|
data/lib/like_query/version.rb
CHANGED