activerecord_where_assoc 1.1.3 → 1.1.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: fd0fae20ed7a2ae8fac19fda0df7f70b9b6a842a6519684c66c571dbf2f57732
4
- data.tar.gz: f570a564494a52517dde7aad62c79b571ab3d1e49d651f32ac2bb86b301fa4f6
3
+ metadata.gz: 4d915a4b0f214283acc2a6ba098018b17fc786f2b801eb2703eba31448b127b9
4
+ data.tar.gz: 614b3c59444a0f6676b63f2499718b16f95ac1d1b010e18e322b10d25be21e1a
5
5
  SHA512:
6
- metadata.gz: 240832561dd8eb5cc93ff3ebc239a0aedf8f9f79520a6404ffe6ac8f9d1b2cacd5f0057d85066ed889b62f16b5e85125acb8b943c91fa72ab0450a366d7d7569
7
- data.tar.gz: 060f842df0bd69b72ac0e6f0a64ef222b347047d693046abe83a9bfdd6797109e202bcccc32f75a3e7bc4349f1b5a50c94982102571a699b113e65331ebca459
6
+ metadata.gz: 1baf41c6ae6094045794f1c5a01c4ff3ab1218d9bc027b51e038667a76d210aa7c8819a1eb61404032fb906233400a9da2f7112a94e0610e5b546c1ef7373934
7
+ data.tar.gz: a1fbc573c244b8ea12cf8bd96b0de0ab248bc14ef5eeb5f1503715951e746ccae9e103fa98baee2f666c971496732bd4f938ece8d77cea6770ad1614d3feed43
data/CHANGELOG.md CHANGED
@@ -1,12 +1,16 @@
1
1
  # Unreleased
2
2
 
3
+ # 1.1.4 - 2023-10-10
4
+
5
+ * Add compatibility for Rails 7.1
6
+
3
7
  # 1.1.3 - 2022-08-16
4
8
 
5
9
  * Add support for associations defined on abstract models
6
10
 
7
11
  # 1.1.2 - 2020-12-24
8
12
 
9
- * Add compatiblity for Rails 6.1
13
+ * Add compatibility for Rails 6.1
10
14
 
11
15
  # 1.1.1 - 2020-04-13
12
16
 
@@ -91,5 +91,15 @@ module ActiveRecordWhereAssoc
91
91
  reflection.is_a?(ActiveRecord::Reflection::ThroughReflection)
92
92
  end
93
93
  end
94
+
95
+ if ActiveRecord.gem_version >= Gem::Version.new("7.1.0.alpha")
96
+ def self.null_relation?(reflection)
97
+ reflection.null_relation?
98
+ end
99
+ else
100
+ def self.null_relation?(reflection)
101
+ reflection.is_a?(ActiveRecord::NullRelation)
102
+ end
103
+ end
94
104
  end
95
105
  end
@@ -13,7 +13,7 @@ module ActiveRecordWhereAssoc
13
13
  # => "EXISTS (SELECT... *relation1*) OR EXISTS (SELECT... *relation2*)"
14
14
  def self.sql_for_any_exists(relations)
15
15
  relations = [relations] unless relations.is_a?(Array)
16
- relations = relations.reject { |rel| rel.is_a?(ActiveRecord::NullRelation) }
16
+ relations = relations.reject { |rel| ActiveRecordCompat.null_relation?(rel) }
17
17
  sqls = relations.map { |rel| "EXISTS (#{rel.select('1').to_sql})" }
18
18
  if sqls.size > 1
19
19
  "(#{sqls.join(" OR ")})" # Parens needed when embedding the sql in a `where`, because the OR could make things wrong
@@ -33,7 +33,7 @@ module ActiveRecordWhereAssoc
33
33
  # => "SUM((SELECT... *relation1*)) + SUM((SELECT... *relation2*))"
34
34
  def self.sql_for_sum_of_counts(relations)
35
35
  relations = [relations] unless relations.is_a?(Array)
36
- relations = relations.reject { |rel| rel.is_a?(ActiveRecord::NullRelation) }
36
+ relations = relations.reject { |rel| ActiveRecordCompat.null_relation?(rel) }
37
37
  # Need the double parentheses
38
38
  relations.map { |rel| "SUM((#{rel.to_sql}))" }.join(" + ").presence || "0"
39
39
  end
@@ -85,7 +85,7 @@ module ActiveRecordWhereAssoc
85
85
  end
86
86
 
87
87
  nested_relations = relations_on_association(record_class, association_names, given_conditions, options, deepest_scope_mod, NestWithSumBlock)
88
- nested_relations = nested_relations.reject { |rel| rel.is_a?(ActiveRecord::NullRelation) }
88
+ nested_relations = nested_relations.reject { |rel| ActiveRecordCompat.null_relation?(rel) }
89
89
  nested_relations.map { |nr| "COALESCE((#{nr.to_sql}), 0)" }.join(" + ").presence || "0"
90
90
  end
91
91
 
@@ -334,7 +334,7 @@ module ActiveRecordWhereAssoc
334
334
  end
335
335
 
336
336
  # No need to do transformations if this is already a NullRelation
337
- return current_scope if current_scope.is_a?(ActiveRecord::NullRelation)
337
+ return current_scope if ActiveRecordCompat.null_relation?(current_scope)
338
338
 
339
339
  current_scope = current_scope.limit(1) if reflection.macro == :has_one
340
340
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecordWhereAssoc
4
- VERSION = "1.1.3".freeze
4
+ VERSION = "1.1.4".freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_where_assoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxime Handfield Lapointe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-16 00:00:00.000000000 Z
11
+ date: 2023-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -31,6 +31,9 @@ dependencies:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.15'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '2.6'
34
37
  type: :development
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -38,6 +41,9 @@ dependencies:
38
41
  - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: '1.15'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.6'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: minitest
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -190,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
196
  - !ruby/object:Gem::Version
191
197
  version: '0'
192
198
  requirements: []
193
- rubygems_version: 3.3.7
199
+ rubygems_version: 3.4.10
194
200
  signing_key:
195
201
  specification_version: 4
196
202
  summary: Make ActiveRecord do conditions on your associations