active_record_extended 2.0.3 → 2.1.0

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: bbcdc3e208ac89fd2d55b8944ad7c0483e57f21a89941a4848beb548b56ce293
4
- data.tar.gz: 10465bfe73686aae4fad33a7da0e533ed22401c68da5655654e1538a8bbb34c0
3
+ metadata.gz: 7f3f7041cc4869183bc20b38f8387bd8f3f216225990a62ec0c4e0fba5f847dd
4
+ data.tar.gz: c61e5ad1c2fae32a5dbfe8660bb888d85f255f285a2df8b1f02206f51cbd71b7
5
5
  SHA512:
6
- metadata.gz: 1ed8f4d6fe19c384bbb8add11443cc78b6f23cf4adc1808bdd0a1b6328a2dbeac22d4e0fa8fc6257dde505646d1c3613ed90711bbd36321cbb74231cf621958d
7
- data.tar.gz: e139454fc996ad112d70332e39b002ba164d2172100f6b61f2494f090a0a3afe16c0e5e51998ab8f8cb8e839c6b0cb1104d152f821ae65d55bec4c83ec9c990a
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: 2.7.x
59
- - Latest Rails supported: 6.1.x
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
- expect_these_users = Person.where(id: 2..4)
652
+ except_these_users = Person.where(id: 2..4)
653
653
 
654
- Person.union_except(users, expect_these_users) #=> [#<Person id: 1, ..>, #<Person id: 5,..>]
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, expect_these_users).union(Person.where(id: 20))
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 ActiveRecord::VERSION::MAJOR == 6 && ActiveRecord::VERSION::MINOR == 1
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecordExtended
4
- VERSION = "2.0.3"
4
+ VERSION = "2.1.0"
5
5
  end
@@ -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.id = users.id")
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.id = users.id")
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.id = users.id") # Y should reject X's CTE (FIFO)
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])
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "database_cleaner"
4
4
 
5
- DatabaseCleaner.strategy = :truncation
5
+ DatabaseCleaner.strategy = :transaction
6
6
 
7
7
  RSpec.configure do |config|
8
8
  config.before do
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.3
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: 2021-06-25 00:00:00.000000000 Z
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: '6.2'
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: '6.2'
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.0.6
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