activerecord-filter 6.0.0.6 → 6.0.0.7

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: c34aa8bbd31df158c37ad5a80c46c31dff156bfb2a6e0bbb7e699d8919eb9aa1
4
- data.tar.gz: eb154ad06ccc2b7b24c4b7ebea90bd4708b95a92db2b7d8fd92f74e2ca71c4c6
3
+ metadata.gz: f04e35c30cfd4a96db7ba90fa1221a808121bacde16bdb70080e105274ae33d5
4
+ data.tar.gz: 5aabf016e7b0cec65b87b09f191fd0da5eb55b0f48cdf94cf4f1727b2c0867af
5
5
  SHA512:
6
- metadata.gz: 8d715a7a707abc56c16512e2aee2fe4fd4995e82466c3651d2caf14d38bb72f0201e0445c72614c4d295d05ccc6adf66666a1287644b33612d14aa472de804b9
7
- data.tar.gz: 2f4535f34a7e762c4ce68abb18530e7f0b9ca9b7f8bd6a16e6389626f806806bc89a486104c17d61cb7361dc106437a203d0fe598ce8ace34136c23048282b66
6
+ metadata.gz: af710f6e3adfd0b3dab81c34a9ae1b2578e9d6047f81c0fed362e30dd97a06ee110eb189eb670bd3e0875792196a36f574e35051585aef37ec0eaca4b4849b69
7
+ data.tar.gz: 869eab8791079a03a395f45ce510d31f05fb0399914ab6996cf8ef4ff4f3450da6a70941cd6068c24a193d4923ac12a539aea4620f16da292c9ae610b77a4419
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  Installtion
6
6
  -----------
7
7
 
8
- - Add `gem 'activerecord-filter', require: 'active_record/filter'
8
+ - Add `gem 'activerecord-filter', require: 'active_record/filter'`
9
9
  - Run `bundle install`
10
10
 
11
11
  Examples
@@ -14,48 +14,89 @@ Examples
14
14
  Normal columns:
15
15
 
16
16
  ```ruby
17
- Property.filter(:id => 5).to_sql
18
- # => "...WHERE properties.id = 5"
17
+ Property.filter(id: 5).to_sql
18
+ Property.filter(id: {eq: 5}).to_sql
19
+ Property.filter(id: {equal_to: 5}).to_sql
20
+ # => "... WHERE properties.id = 5 ..."
19
21
 
20
- Property.filter(:id => [5, 10, 15]).to_sql
21
- # => "...WHERE properties.id IN (5, 10, 15)"
22
+ Property.filter(id: {not: 5}).to_sql
23
+ Property.filter(id: {neq: 5}).to_sql
24
+ Property.filter(id: {not_equal: 5}).to_sql
25
+ # => "... WHERE properties.id != 5 ..."
22
26
 
23
- Property.filter(:id => {:gt => 5}).to_sql
24
- # => "...WHERE properties.id > 5"
27
+ Property.filter(id: [5, 10, 15]).to_sql
28
+ # => "... WHERE properties.id IN (5, 10, 15) ..."
25
29
 
26
- Property.filter(:id => {:gte => 5}).to_sql
27
- # => "...WHERE properties.id >= 5"
30
+ Property.filter(id: {in: [5, 10, 15]}).to_sql
31
+ # => "... WHERE properties.id IN (5, 10, 15) ..."
28
32
 
29
- Property.filter(:id => {:lt => 5}).to_sql
30
- # => "...WHERE properties.id < 5"
33
+ Property.filter(id: {not_in: [5, 10, 15]}).to_sql
34
+ # => "... WHERE properties.id NOT IN (5, 10, 15) ..."
31
35
 
32
- Property.filter(:id => {:lte => 5}).to_sql
33
- # => "...WHERE properties.id <= 5"
36
+ Property.filter(id: {gt: 5}).to_sql
37
+ Property.filter(id: {greater_than: 5}).to_sql
38
+ # => "... WHERE properties.id > 5 ..."
34
39
 
35
- Property.filter(:address_id => nil).to_sql
36
- # => "...WHERE properties.address_id IS NULL..."
40
+ Property.filter(id: {gte: 5}).to_sql
41
+ Property.filter(id: {gteq: 5}).to_sql
42
+ Property.filter(id: {greater_than_or_equal_to: 5}).to_sql
43
+ # => "... WHERE properties.id >= 5 ..."
37
44
 
38
- Property.filter(:address_id => false).to_sql
39
- # => "...WHERE properties.address_id IS NULL..."
45
+ Property.filter(id: {lt: 5}).to_sql
46
+ Property.filter(id: {less_than: 5}).to_sql
47
+ # => "... WHERE properties.id < 5 ..."
40
48
 
41
- Property.filter(:address_id => true).to_sql
42
- # => "...WHERE properties.address_id IS NOT NULL..."
49
+ Property.filter(id: {lte: 5}).to_sql
50
+ Property.filter(id: {lteq: 5}).to_sql
51
+ Property.filter(id: {less_than_or_equal_to: 5}).to_sql
52
+ # => "... WHERE properties.id <= 5 ..."
53
+
54
+ Property.filter(address_id: nil).to_sql
55
+ # => "... WHERE properties.address_id IS NULL ..."
56
+
57
+ Property.filter(address_id: false).to_sql
58
+ # => "... WHERE properties.address_id IS NULL ..."
59
+
60
+ Property.filter(boolean_column: false).to_sql
61
+ # => "... WHERE properties.boolean_column = FALSE ..."
62
+
63
+ Property.filter(address_id: true).to_sql
64
+ # => "... WHERE properties.address_id IS NOT NULL ..."
65
+
66
+ Property.filter(boolean_column: true).to_sql
67
+ # => "... WHERE properties.boolean_column = TRUE ..."
68
+ ```
69
+
70
+ String columns:
71
+
72
+ ```ruby
73
+ Property.filter(name: {like: 'nam%'}).to_sql
74
+ # => "... WHERE properties.name LIKE 'nam%' ..."
75
+
76
+ Property.filter(name: {ts_match: 'name'}).to_sql
77
+ # => "... WHERE to_tsvector("properties"."name") @@ to_tsquery('name') ..."
43
78
  ```
44
79
 
45
80
  It can also work with array columns:
46
81
 
47
82
  ```ruby
48
- Property.filter(:tags => 'Skyscraper').to_sql
83
+ Property.filter(tags: 'Skyscraper').to_sql
49
84
  # => "...WHERE properties.tags = '{'Skyscraper'}'..."
50
85
 
51
- Property.filter(:tags => ['Skyscraper', 'Brick']).to_sql
52
- # => "...WHERE (properties.tags = '{"Skyscraper", "Brick"}')..."
86
+ Property.filter(tags: ['Skyscraper', 'Brick']).to_sql
87
+ # => "...WHERE properties.tags = '{"Skyscraper", "Brick"}'..."
88
+
89
+ Property.filter(tags: {overlaps: ['Skyscraper', 'Brick']}).to_sql
90
+ # => "...WHERE properties.tags && '{"Skyscraper", "Brick"}'..."
91
+
92
+ Property.filter(tags: {contains: ['Skyscraper', 'Brick']}).to_sql
93
+ # => "...WHERE accounts.tags @> '{"Skyscraper", "Brick"}'..."
53
94
 
54
- Property.filter(:tags => {overlaps: ['Skyscraper', 'Brick']}).to_sql
55
- # => "...WHERE properties.tags && '{"Skyscraper", "Brick"}')..."
95
+ Property.filter(tags: {excludes: ['Skyscraper', 'Brick']}).to_sql
96
+ # => "...WHERE NOT (accounts.tags @> '{"Skyscraper", "Brick"}')..."
56
97
 
57
- Property.filter(:tags => {contains: ['Skyscraper', 'Brick']}).to_sql
58
- # => "...WHERE accounts.tags @> '{"Skyscraper", "Brick"}')..."
98
+ Property.filter(tags: {contained_by: ['Skyscraper', 'Brick']}).to_sql
99
+ # => "...WHERE accounts.tags <@ '{"Skyscraper", "Brick"}'..."
59
100
  ```
60
101
 
61
102
  And JSON columns:
@@ -70,6 +111,12 @@ Property.filter(metadata: { contains: { key: 'value' } }).to_sql
70
111
  Property.filter(metadata: { has_key: 'key' }).to_sql
71
112
  # => "...WHERE "properties"."metadata" ? 'key'..."
72
113
 
114
+ Property.filter(metadata: { has_keys: ['key1', 'key2'] }).to_sql
115
+ # => "...WHERE "properties"."metadata" ?& array['key1', 'key2']..."
116
+
117
+ Property.filter(metadata: { has_any_key: ['key1', 'key2'] }).to_sql
118
+ # => "...WHERE "properties"."metadata" ?| array['key1', 'key2']..."
119
+
73
120
  Property.filter("metadata.key": { eq: 'value' }).to_sql
74
121
  # => "...WHERE "properties"."metadata" #> '{key}' = 'value'..."
75
122
  ```
@@ -77,7 +124,7 @@ Property.filter("metadata.key": { eq: 'value' }).to_sql
77
124
  It can also sort on relations:
78
125
 
79
126
  ```ruby
80
- Photo.filter(:property => {name: 'Empire State'}).to_sql
81
- # => "...INNER JOIN properties ON properties.id = photos.property_id
82
- # => " WHERE properties.name = 'Empire State'"
83
- ```
127
+ Photo.filter(property: {name: 'Empire State'}).to_sql
128
+ # => "... INNER JOIN properties ON properties.id = photos.property_id ...
129
+ # => "... WHERE properties.name = 'Empire State'"
130
+ ```
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Filter
3
- VERSION = '6.0.0.6'
3
+ VERSION = '6.0.0.7'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0.6
4
+ version: 6.0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Bracy
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-27 00:00:00.000000000 Z
11
+ date: 2020-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 6.0.0.5
33
+ version: 6.0.0.8
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 6.0.0.5
40
+ version: 6.0.0.8
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pg
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -194,7 +194,7 @@ homepage: https://github.com/malomalo/activerecord-filter
194
194
  licenses:
195
195
  - MIT
196
196
  metadata: {}
197
- post_install_message:
197
+ post_install_message:
198
198
  rdoc_options:
199
199
  - "--main"
200
200
  - README.md
@@ -211,8 +211,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
211
  - !ruby/object:Gem::Version
212
212
  version: '0'
213
213
  requirements: []
214
- rubygems_version: 3.0.6
215
- signing_key:
214
+ rubygems_version: 3.1.2
215
+ signing_key:
216
216
  specification_version: 4
217
217
  summary: A safe way to accept user parameters and query against your ActiveRecord
218
218
  Models