where_chain 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_record/where_chain_extensions_rails5.rb +14 -3
- data/lib/where_chain/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc7e391acb640aba967c22926907bc95c610bba037ff38f1890274d751797d50
|
4
|
+
data.tar.gz: ff165ee3f9bda32f0625fc8214f7cfba1f335b273260b008d2e33a26be5505ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77ab8fd3e5f1f8f9aebaa880a420c72200a789cef67c5e5c1da603fa34b8d37b6f76e6a5e8be21381e6de4cc8a036c6a482baf9fe412e09339238de3610e7601
|
7
|
+
data.tar.gz: 7fd1435df353db94e480285f02451f75168486f7d24a3bd04c357cbe4a7de75cd79d226d1b9c8136344e9c246d43fc8e67620cddb4a4866d4aa2f7906e45b399
|
@@ -8,6 +8,7 @@ module ActiveRecord
|
|
8
8
|
|
9
9
|
module QueryMethods
|
10
10
|
class WhereChain
|
11
|
+
include ActiveModel::ForbiddenAttributesProtection
|
11
12
|
include WhereChainSharedMethods
|
12
13
|
|
13
14
|
# Returns a new relation expressing WHERE + NOT condition
|
@@ -30,9 +31,9 @@ module ActiveRecord
|
|
30
31
|
|
31
32
|
opts = sanitize_forbidden_attributes(opts)
|
32
33
|
|
33
|
-
where_clause =
|
34
|
+
where_clause = where_clause_factory_build(opts, rest)
|
34
35
|
|
35
|
-
@scope.references!(PredicateBuilder.references(opts)) if opts.is_a?(Hash)
|
36
|
+
@scope.references!(PredicateBuilder.references(opts.stringify_keys)) if opts.is_a?(Hash)
|
36
37
|
@scope.where_clause += where_clause.invert
|
37
38
|
@scope
|
38
39
|
end
|
@@ -46,7 +47,7 @@ module ActiveRecord
|
|
46
47
|
def prepare_where(node_type, infix, opts, rest)
|
47
48
|
@scope.tap do |s|
|
48
49
|
opts.each_pair do |key, value|
|
49
|
-
equal_where_clause =
|
50
|
+
equal_where_clause = where_clause_factory_build({ key => value }, rest)
|
50
51
|
equal_where_clause_predicate = equal_where_clause.send(:predicates).first
|
51
52
|
|
52
53
|
new_predicate = arel_node(node_type, infix, equal_where_clause_predicate)
|
@@ -69,6 +70,16 @@ module ActiveRecord
|
|
69
70
|
Relation::WhereClause.new([new_predicate])
|
70
71
|
end
|
71
72
|
end
|
73
|
+
|
74
|
+
# Active Record 6.1 removed the where_clause_factory.build method
|
75
|
+
# method was replaced by build_where_clause
|
76
|
+
def where_clause_factory_build(opts, rest = [])
|
77
|
+
if ActiveRecord.version.release >= Gem::Version.new('6.1.0')
|
78
|
+
@scope.send(:build_where_clause, opts, rest)
|
79
|
+
else
|
80
|
+
@scope.send(:where_clause_factory).build(opts, rest)
|
81
|
+
end
|
82
|
+
end
|
72
83
|
end
|
73
84
|
end
|
74
85
|
end
|
data/lib/where_chain/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: where_chain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Ruszkiewicz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|