active_record_extended 3.1.0 → 3.2.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2611c1b573495ab42f5a15ff8d85bdc8ba95bbe8d077ae037a5eae8e8f29f2c6
|
4
|
+
data.tar.gz: 4d6c36a2e09b490969f8f152bda00a45180bbcd0a728fb7344e058faa96da10c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bbb84f095b990140d2cc7f6e11de1c7b11a039d4f6cdf02f910c470c9dd5cf71df71dcd344140e02baaec9969000c0d665845e830fff7aeddf3111339b578c2
|
7
|
+
data.tar.gz: cc11bebd6832cdb82cacc31d5af01d8dc9123414ef5f2ed3c7c8e995a3e2005352444cd247c79de081f473d9c8fcde7758d7cbdfe156c2b909bcea2f78a24c6d
|
data/README.md
CHANGED
@@ -52,12 +52,12 @@ Active Record Extended is essentially providing users with the other half of Pos
|
|
52
52
|
## Compatibility
|
53
53
|
|
54
54
|
This package is designed align and work with any officially supported Ruby and Rails versions.
|
55
|
-
- Minimum Ruby Version: 2.
|
55
|
+
- Minimum Ruby Version: 2.7.x **(EOL warning!)**
|
56
56
|
- Minimum Rails Version: 5.2.x **(EOL warning!)**
|
57
57
|
- Minimum Postgres Version: 11.x **(EOL warning!)**
|
58
|
-
- Latest Ruby supported: 3.
|
58
|
+
- Latest Ruby supported: 3.2.x
|
59
59
|
- Latest Rails supported: 7.0.x
|
60
|
-
- Postgres: 11-current(
|
60
|
+
- Postgres: 11-current(15) (probably works with most older versions to a certain point)
|
61
61
|
|
62
62
|
## Installation
|
63
63
|
|
@@ -5,23 +5,15 @@ module ActiveRecordExtended
|
|
5
5
|
module AnyOf
|
6
6
|
def any_of(*queries)
|
7
7
|
queries = hash_map_queries(queries)
|
8
|
-
build_query(queries) do |arel_query
|
9
|
-
|
10
|
-
@scope.where(unprepared_query(arel_query.to_sql), *binds)
|
11
|
-
else
|
12
|
-
@scope.where(arel_query)
|
13
|
-
end
|
8
|
+
build_query(queries) do |arel_query|
|
9
|
+
@scope.where(arel_query)
|
14
10
|
end
|
15
11
|
end
|
16
12
|
|
17
13
|
def none_of(*queries)
|
18
14
|
queries = hash_map_queries(queries)
|
19
|
-
build_query(queries) do |arel_query
|
20
|
-
|
21
|
-
@scope.where.not(unprepared_query(arel_query.to_sql), *binds)
|
22
|
-
else
|
23
|
-
@scope.where.not(arel_query)
|
24
|
-
end
|
15
|
+
build_query(queries) do |arel_query|
|
16
|
+
@scope.where.not(arel_query)
|
25
17
|
end
|
26
18
|
end
|
27
19
|
|
@@ -37,7 +29,7 @@ module ActiveRecordExtended
|
|
37
29
|
|
38
30
|
def build_query(queries)
|
39
31
|
query_map = construct_query_mappings(queries)
|
40
|
-
query = yield(query_map[:arel_query]
|
32
|
+
query = yield(query_map[:arel_query])
|
41
33
|
query
|
42
34
|
.joins(query_map[:joins].to_a)
|
43
35
|
.includes(query_map[:includes].to_a)
|
@@ -51,29 +43,13 @@ module ActiveRecordExtended
|
|
51
43
|
query_map[:joins] << translate_reference(query.joins_values) if query.joins_values.any?
|
52
44
|
query_map[:includes] << translate_reference(query.includes_values) if query.includes_values.any?
|
53
45
|
query_map[:references] << translate_reference(query.references_values) if query.references_values.any?
|
54
|
-
query_map[:binds] += bind_attributes(query)
|
55
46
|
query.arel.constraints.reduce(:and)
|
56
47
|
end.reduce(:or)
|
57
48
|
end
|
58
49
|
end
|
59
50
|
|
60
|
-
# Rails 5.1 fix
|
61
|
-
# In Rails 5.2 the arel table maintains attribute binds
|
62
|
-
def bind_attributes(query)
|
63
|
-
return [] unless query.respond_to?(:bound_attributes)
|
64
|
-
|
65
|
-
query.bound_attributes.map(&:value)
|
66
|
-
end
|
67
|
-
|
68
|
-
# Rails 5.1 fix
|
69
|
-
def unprepared_query(query)
|
70
|
-
query.gsub(/((?<!\\)'.*?(?<!\\)'|(?<!\\)".*?(?<!\\)")|(=\ \$\d+)/) do |match|
|
71
|
-
Regexp.last_match(2)&.gsub(/=\ \$\d+/, "= ?") || match
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
51
|
def translate_reference(reference)
|
76
|
-
reference.
|
52
|
+
reference.filter_map { |ref| ref.try(:to_sql) || ref }
|
77
53
|
end
|
78
54
|
|
79
55
|
def generate_where_clause(query)
|
@@ -107,7 +107,7 @@ module ActiveRecordExtended
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def union(opts = :chain, *args)
|
110
|
-
return UnionChain.new(spawn) if
|
110
|
+
return UnionChain.new(spawn) if :chain == opts
|
111
111
|
|
112
112
|
opts.nil? ? self : spawn.union!(opts, *args, chain_method: __callee__)
|
113
113
|
end
|
@@ -121,7 +121,7 @@ module ActiveRecordExtended
|
|
121
121
|
def union!(opts = :chain, *args, chain_method: :union)
|
122
122
|
union_chain = UnionChain.new(self)
|
123
123
|
chain_method ||= :union
|
124
|
-
return union_chain if
|
124
|
+
return union_chain if :chain == opts
|
125
125
|
|
126
126
|
union_chain.public_send(chain_method, *([opts] + args))
|
127
127
|
end
|
@@ -161,12 +161,17 @@ module ActiveRecordExtended
|
|
161
161
|
end
|
162
162
|
|
163
163
|
# @param [Hash, WithCTE] opts
|
164
|
-
def with!(opts = :chain, *
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
164
|
+
def with!(opts = :chain, *rest)
|
165
|
+
case opts
|
166
|
+
when :chain
|
167
|
+
WithChain.new(self)
|
168
|
+
when :recursive
|
169
|
+
WithChain.new(self).recursive(*rest)
|
170
|
+
else
|
171
|
+
tap do |scope|
|
172
|
+
scope.cte ||= WithCTE.new(self)
|
173
|
+
scope.cte.pipe_cte_with!(opts)
|
174
|
+
end
|
170
175
|
end
|
171
176
|
end
|
172
177
|
|
@@ -176,7 +181,6 @@ module ActiveRecordExtended
|
|
176
181
|
cte_statements = cte.map do |name, expression|
|
177
182
|
grouped_expression = cte.generate_grouping(expression)
|
178
183
|
cte_name = cte.to_arel_sql(cte.double_quote(name.to_s))
|
179
|
-
|
180
184
|
grouped_expression = add_materialized_modifier(grouped_expression, cte, name)
|
181
185
|
|
182
186
|
Arel::Nodes::As.new(cte_name, grouped_expression)
|
@@ -193,9 +197,9 @@ module ActiveRecordExtended
|
|
193
197
|
|
194
198
|
def add_materialized_modifier(expression, cte, name)
|
195
199
|
if cte.materialized_key?(name)
|
196
|
-
Arel
|
200
|
+
Arel.sql("MATERIALIZED #{expression.to_sql}")
|
197
201
|
elsif cte.not_materialized_key?(name)
|
198
|
-
Arel
|
202
|
+
Arel.sql("NOT MATERIALIZED #{expression.to_sql}")
|
199
203
|
else
|
200
204
|
expression
|
201
205
|
end
|
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: 3.1
|
4
|
+
version: 3.2.1
|
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: 2023-02-17 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.2'
|
22
22
|
- - "<"
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 7.
|
24
|
+
version: 7.2.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.2'
|
32
32
|
- - "<"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 7.
|
34
|
+
version: 7.2.0
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: pg
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '3.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec-sqlimit
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.0.5
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.0.5
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: simplecov
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -167,14 +181,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
167
181
|
requirements:
|
168
182
|
- - ">="
|
169
183
|
- !ruby/object:Gem::Version
|
170
|
-
version: '2.
|
184
|
+
version: '2.7'
|
171
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
186
|
requirements:
|
173
187
|
- - ">="
|
174
188
|
- !ruby/object:Gem::Version
|
175
189
|
version: '0'
|
176
190
|
requirements: []
|
177
|
-
rubygems_version: 3.
|
191
|
+
rubygems_version: 3.4.1
|
178
192
|
signing_key:
|
179
193
|
specification_version: 4
|
180
194
|
summary: Adds extended functionality to Activerecord Postgres implementation
|