dbee-active_record 2.0.3 → 2.0.4

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
  SHA256:
3
- metadata.gz: 382941d933c56ac2efc758119b32568638f6ac4d2842bcfe0e84cbb6d03f5994
4
- data.tar.gz: 80a5aedc314d37202c0e976160168c8ecbeaa17e64c0f4be44bdfa48c97a6e1e
3
+ metadata.gz: 9f50827b6f31ffb9749796b4532b8a48f704c522be4e0011b7e9a58ed716dd26
4
+ data.tar.gz: e9469a99514bfdfbe03da6cdcda339aef1b12b2d829a82d7e2278a22b006f0b3
5
5
  SHA512:
6
- metadata.gz: 68df7e7994baf9cb29ea0ea6d2860e4bcf2509af4e046568064458b5f6309d0cba3d791d8b1461080bcd4e73706cd00b696106f8ede28bb89afc0c0529801f30
7
- data.tar.gz: 15a4a9fdd0597b4cfa69e2a216c30f4ab51a64521c419f51316b12cfed21ebc7d7f4c87871c35a3958f4a3a0b918cb7d15616d2c1986e4ae0f831062a1995fd7
6
+ metadata.gz: 7162ee879530dd36b2078a347b6fade9a5e5ce8e79f47709b33b11cb308303195cbafb3e6096a1529ddb7b7c23da6a19caccdc61356f29dd14b48b4e077cc041
7
+ data.tar.gz: 6d19989ed13fd0e2d7a88b3341309cf517aede0f4924c8f76f1325685a099b4b20985774adb445b0bb3487c9d91568500a86c767237618f57194e2806ee0fa93
data/CHANGELOG.md CHANGED
@@ -1,4 +1,9 @@
1
- # 2.0.3 (January 7th, 2019)
1
+ # 2.0.4 (February 13th, 2020)
2
+
3
+ * use Arel#in for Equal filters when there is more than one value
4
+ * use Arel#not_in for NotEqual filters when there are is than one value
5
+
6
+ # 2.0.3 (January 7th, 2020)
2
7
 
3
8
  * Added/tested support for Dbee 2.0.3
4
9
  * Added support for Ruby 2.6.5
@@ -31,6 +31,24 @@ module Dbee
31
31
  private_constant :FILTER_EVALUATORS
32
32
 
33
33
  def make(filter, arel_column)
34
+ values = normalize(filter.value)
35
+
36
+ if filter.is_a?(Query::Filters::Equals) && values.length > 1
37
+ arel_column.in(values)
38
+ elsif filter.is_a?(Query::Filters::NotEquals) && values.length > 1
39
+ arel_column.not_in(values)
40
+ else
41
+ use_or(filter, arel_column)
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ def normalize(value)
48
+ value ? Array(value).flatten : [nil]
49
+ end
50
+
51
+ def use_or(filter, arel_column)
34
52
  predicates = normalize(filter.value).map do |coerced_value|
35
53
  method = FILTER_EVALUATORS[filter.class]
36
54
 
@@ -43,12 +61,6 @@ module Dbee
43
61
  memo.or(predicate)
44
62
  end
45
63
  end
46
-
47
- private
48
-
49
- def normalize(value)
50
- value ? Array(value).flatten : [nil]
51
- end
52
64
  end
53
65
  end
54
66
  end
@@ -10,7 +10,7 @@
10
10
  module Dbee
11
11
  module Providers
12
12
  class ActiveRecordProvider
13
- VERSION = '2.0.3'
13
+ VERSION = '2.0.4'
14
14
  end
15
15
  end
16
16
  end
@@ -45,6 +45,10 @@ query:
45
45
  - 'Netflix'
46
46
  - 'Hulu'
47
47
  key_path: name
48
+ - type: not_equals
49
+ value:
50
+ - 'YouTube Super Video'
51
+ key_path: name
48
52
  - type: not_contain
49
53
  value:
50
54
  - 'tfli'
@@ -59,67 +63,71 @@ sqlite_readable: |+
59
63
  SELECT "theaters"."id" AS 'ID #',
60
64
  "theaters"."name" AS 'name'
61
65
  FROM "theaters" "theaters"
62
- WHERE ("theaters"."name" = 'AMC' OR "theaters"."name" = 'Regal') AND
66
+ WHERE "theaters"."name" IN ('AMC', 'Regal') AND
63
67
  "theaters"."name" LIKE 'A%' AND
64
68
  "theaters"."name" LIKE '%m%' AND
65
69
  "theaters"."active" = 'false' AND
66
- (("theaters"."active" = 't' OR "theaters"."active" = 'f') OR "theaters"."active" IS NULL) AND
67
- (("theaters"."inspected" = 'f' OR "theaters"."inspected" = 't') OR "theaters"."inspected" IS NULL) AND
70
+ "theaters"."active" IN ('t', 'f', NULL) AND
71
+ "theaters"."inspected" IN ('f', 't', NULL) AND
68
72
  "theaters"."created_at" <= '2019-03-04' AND
69
73
  "theaters"."created_at" < '2018-03-04' AND
70
74
  "theaters"."created_at" >= '2001-03-04' AND
71
75
  "theaters"."created_at" > '2002-03-04' AND
72
- ("theaters"."name" != 'Netflix' OR "theaters"."name" != 'Hulu') AND
76
+ "theaters"."name" NOT IN ('Netflix', 'Hulu') AND
77
+ "theaters"."name" != 'YouTube Super Video' AND
73
78
  ("theaters"."name" NOT LIKE '%tfli%' OR "theaters"."name" NOT LIKE '%ul%') AND
74
79
  ("theaters"."name" NOT LIKE 'netf%' OR "theaters"."name" NOT LIKE 'hu%')
75
80
  sqlite_not_readable: |+
76
81
  SELECT "t0"."id" AS 'c0',
77
82
  "t0"."name" AS 'c1'
78
83
  FROM "theaters" "t0"
79
- WHERE ("t0"."name" = 'AMC' OR "t0"."name" = 'Regal') AND
84
+ WHERE "t0"."name" IN ('AMC', 'Regal') AND
80
85
  "t0"."name" LIKE 'A%' AND
81
86
  "t0"."name" LIKE '%m%' AND
82
87
  "t0"."active" = 'false' AND
83
- (("t0"."active" = 't' OR "t0"."active" = 'f') OR "t0"."active" IS NULL) AND
84
- (("t0"."inspected" = 'f' OR "t0"."inspected" = 't') OR "t0"."inspected" IS NULL) AND
88
+ "t0"."active" IN ('t', 'f', NULL) AND
89
+ "t0"."inspected" IN ('f', 't', NULL) AND
85
90
  "t0"."created_at" <= '2019-03-04' AND
86
91
  "t0"."created_at" < '2018-03-04' AND
87
92
  "t0"."created_at" >= '2001-03-04' AND
88
93
  "t0"."created_at" > '2002-03-04' AND
89
- ("t0"."name" != 'Netflix' OR "t0"."name" != 'Hulu') AND
94
+ "t0"."name" NOT IN ('Netflix', 'Hulu') AND
95
+ "t0"."name" != 'YouTube Super Video' AND
90
96
  ("t0"."name" NOT LIKE '%tfli%' OR "t0"."name" NOT LIKE '%ul%') AND
91
97
  ("t0"."name" NOT LIKE 'netf%' OR "t0"."name" NOT LIKE 'hu%')
92
98
  mysql_readable: |+
93
99
  SELECT `theaters`.`id` AS 'ID #',
94
100
  `theaters`.`name` AS 'name'
95
101
  FROM `theaters` `theaters`
96
- WHERE (`theaters`.`name` = 'AMC' OR `theaters`.`name` = 'Regal') AND
102
+ WHERE `theaters`.`name` IN ('AMC', 'Regal') AND
97
103
  `theaters`.`name` LIKE 'A%' AND
98
104
  `theaters`.`name` LIKE '%m%' AND
99
105
  `theaters`.`active` = 'false' AND
100
- ((`theaters`.`active` = TRUE OR `theaters`.`active` = FALSE) OR `theaters`.`active` IS NULL) AND
101
- ((`theaters`.`inspected` = FALSE OR `theaters`.`inspected` = TRUE) OR `theaters`.`inspected` IS NULL) AND
106
+ `theaters`.`active` IN (TRUE, FALSE, NULL) AND
107
+ `theaters`.`inspected` IN (FALSE, TRUE, NULL) AND
102
108
  `theaters`.`created_at` <= '2019-03-04' AND
103
109
  `theaters`.`created_at` < '2018-03-04' AND
104
110
  `theaters`.`created_at` >= '2001-03-04' AND
105
111
  `theaters`.`created_at` > '2002-03-04' AND
106
- (`theaters`.`name` != 'Netflix' OR `theaters`.`name` != 'Hulu') AND
112
+ `theaters`.`name` NOT IN ('Netflix', 'Hulu') AND
113
+ `theaters`.`name` != 'YouTube Super Video' AND
107
114
  (`theaters`.`name` NOT LIKE '%tfli%' OR `theaters`.`name` NOT LIKE '%ul%') AND
108
115
  (`theaters`.`name` NOT LIKE 'netf%' OR `theaters`.`name` NOT LIKE 'hu%')
109
116
  mysql_not_readable: |+
110
117
  SELECT `t0`.`id` AS 'c0',
111
118
  `t0`.`name` AS 'c1'
112
119
  FROM `theaters` `t0`
113
- WHERE (`t0`.`name` = 'AMC' OR `t0`.`name` = 'Regal') AND
120
+ WHERE `t0`.`name` IN ('AMC', 'Regal') AND
114
121
  `t0`.`name` LIKE 'A%' AND
115
122
  `t0`.`name` LIKE '%m%' AND
116
123
  `t0`.`active` = 'false' AND
117
- ((`t0`.`active` = TRUE OR `t0`.`active` = FALSE) OR `t0`.`active` IS NULL) AND
118
- ((`t0`.`inspected` = FALSE OR `t0`.`inspected` = TRUE) OR `t0`.`inspected` IS NULL) AND
124
+ `t0`.`active` IN (TRUE, FALSE, NULL) AND
125
+ `t0`.`inspected` IN (FALSE, TRUE, NULL) AND
119
126
  `t0`.`created_at` <= '2019-03-04' AND
120
127
  `t0`.`created_at` < '2018-03-04' AND
121
128
  `t0`.`created_at` >= '2001-03-04' AND
122
129
  `t0`.`created_at` > '2002-03-04' AND
123
- (`t0`.`name` != 'Netflix' OR `t0`.`name` != 'Hulu') AND
130
+ `t0`.`name` NOT IN ('Netflix', 'Hulu') AND
131
+ `t0`.`name` != 'YouTube Super Video' AND
124
132
  (`t0`.`name` NOT LIKE '%tfli%' OR `t0`.`name` NOT LIKE '%ul%') AND
125
133
  (`t0`.`name` NOT LIKE 'netf%' OR `t0`.`name` NOT LIKE 'hu%')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbee-active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ruggio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-07 00:00:00.000000000 Z
11
+ date: 2020-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord