active_record_extended 2.0.3 → 2.1.0
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/README.md +5 -5
- data/lib/active_record_extended/query_methods/where_chain.rb +3 -1
- data/lib/active_record_extended/version.rb +1 -1
- data/spec/query_methods/unionize_spec.rb +1 -1
- data/spec/query_methods/with_cte_spec.rb +3 -3
- data/spec/support/database_cleaner.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f3f7041cc4869183bc20b38f8387bd8f3f216225990a62ec0c4e0fba5f847dd
|
4
|
+
data.tar.gz: c61e5ad1c2fae32a5dbfe8660bb888d85f255f285a2df8b1f02206f51cbd71b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c27cf6541f3e11a3beb00263be7c1478e8f4ddb64b0121ed141347ca995252453864bd3cf0992038b7ea2aa1c409f50792800fdf909d8e544edd470af35231fa
|
7
|
+
data.tar.gz: d0426b00cca79e3d0d145fb87fdd05c25611ff5bfde95c8c1845a281786bd4c7e6bfbd866df46cb8ce1ccd45ab5b4bd91aa83e6c21db879721436574f90087cf
|
data/README.md
CHANGED
@@ -55,8 +55,8 @@ This package is designed align and work with any officially supported Ruby and R
|
|
55
55
|
- Minimum Ruby Version: 2.4.x **(EOL warning!)**
|
56
56
|
- Minimum Rails Version: 5.1.x **(EOL warning!)**
|
57
57
|
- Minimum Postgres Version: 9.6.x **(EOL warning!)**
|
58
|
-
- Latest Ruby supported:
|
59
|
-
- Latest Rails supported:
|
58
|
+
- Latest Ruby supported: 3.0.x
|
59
|
+
- Latest Rails supported: 7.0.x
|
60
60
|
- Postgres: 9.6-current(13) (probably works with most older versions to a certain point)
|
61
61
|
|
62
62
|
## Installation
|
@@ -649,12 +649,12 @@ SELECT "people".*
|
|
649
649
|
|
650
650
|
```ruby
|
651
651
|
users = Person.where(id: 1..5)
|
652
|
-
|
652
|
+
except_these_users = Person.where(id: 2..4)
|
653
653
|
|
654
|
-
Person.union_except(users,
|
654
|
+
Person.union_except(users, except_these_users) #=> [#<Person id: 1, ..>, #<Person id: 5,..>]
|
655
655
|
|
656
656
|
# You can also chain union's
|
657
|
-
Person.union.except(users,
|
657
|
+
Person.union.except(users, except_these_users).union(Person.where(id: 20))
|
658
658
|
```
|
659
659
|
|
660
660
|
Query Output
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
module ActiveRecordExtended
|
4
4
|
module WhereChain
|
5
|
+
AR_VERSION_AT_LEAST_6_1 = ActiveRecord.version >= Gem::Version.new('6.1')
|
6
|
+
|
5
7
|
# Finds Records that have an array column that contain any a set of values
|
6
8
|
# User.where.overlap(tags: [1,2])
|
7
9
|
# # SELECT * FROM users WHERE tags && {1,2}
|
@@ -106,7 +108,7 @@ module ActiveRecordExtended
|
|
106
108
|
end
|
107
109
|
|
108
110
|
def build_where_clause_for(scope, opts, rest)
|
109
|
-
if
|
111
|
+
if AR_VERSION_AT_LEAST_6_1
|
110
112
|
scope.send(:build_where_clause, opts, rest)
|
111
113
|
else
|
112
114
|
scope.send(:where_clause_factory).build(opts, rest)
|
@@ -91,7 +91,7 @@ RSpec.describe "Active Record Union Methods" do
|
|
91
91
|
User.select(:id, "profile_ls.likes").joins(:profile_l).where("profile_ls.likes < 150")
|
92
92
|
)
|
93
93
|
|
94
|
-
expect(query.pluck(:id)).to have_attributes(size: 1).and(eq([user_one_pl.id]))
|
94
|
+
expect(query.pluck(:id)).to have_attributes(size: 1).and(eq([user_one_pl.user.id]))
|
95
95
|
expect(query.first.likes).to eq(user_one_pl.likes)
|
96
96
|
end
|
97
97
|
end
|
@@ -12,14 +12,14 @@ RSpec.describe "Active Record With CTE Query Methods" do
|
|
12
12
|
context "when using as a standalone query" do
|
13
13
|
it "should only return a person with less than 300 likes" do
|
14
14
|
query = User.with(profile: ProfileL.where("likes < 300"))
|
15
|
-
.joins("JOIN profile ON profile.
|
15
|
+
.joins("JOIN profile ON profile.user_id = users.id")
|
16
16
|
|
17
17
|
expect(query).to match_array([user_one])
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should return anyone with likes greater than or equal to 200" do
|
21
21
|
query = User.with(profile: ProfileL.where("likes >= 200"))
|
22
|
-
.joins("JOIN profile ON profile.
|
22
|
+
.joins("JOIN profile ON profile.user_id = users.id")
|
23
23
|
|
24
24
|
expect(query).to match_array([user_one, user_two])
|
25
25
|
end
|
@@ -39,7 +39,7 @@ RSpec.describe "Active Record With CTE Query Methods" do
|
|
39
39
|
it "should contain a unique list of ordered CTE keys when merging in multiple children" do
|
40
40
|
x = User.with(profile: ProfileL.where("likes < 300"))
|
41
41
|
y = User.with(profile: ProfileL.where("likes > 400"))
|
42
|
-
z = y.merge(x).joins("JOIN profile ON profile.
|
42
|
+
z = y.merge(x).joins("JOIN profile ON profile.user_id = users.id") # Y should reject X's CTE (FIFO)
|
43
43
|
query = User.with(my_profile: z).joins("JOIN my_profile ON my_profile.id = users.id")
|
44
44
|
|
45
45
|
expect(query.cte.with_keys).to eq([:profile, :my_profile])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_extended
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- George Protacio-Karaszi
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-01-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '5.1'
|
22
22
|
- - "<"
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version:
|
24
|
+
version: 7.1.0
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
version: '5.1'
|
32
32
|
- - "<"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 7.1.0
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: ar_outer_joins
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
213
|
- !ruby/object:Gem::Version
|
214
214
|
version: '0'
|
215
215
|
requirements: []
|
216
|
-
rubygems_version: 3.
|
216
|
+
rubygems_version: 3.1.4
|
217
217
|
signing_key:
|
218
218
|
specification_version: 4
|
219
219
|
summary: Adds extended functionality to Activerecord Postgres implementation
|