arel_extensions 1.2.19 → 1.2.23

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: 8b1349341148022d22f5f1db49226c8279bfc9474e48dfbeed4741f68dedc1bc
4
- data.tar.gz: 8ef43ffbefa6e47f95bde8e9212b195e877cd97700ec113cb0a394fd0eff8014
3
+ metadata.gz: dd9036278df59b6ea574de919e8c2ad7a4326aa40466b00f84be093d8352e591
4
+ data.tar.gz: d3cca86041854d9d1dcc940782719d95f21c26d02f6afc8cb6442a4173bf40b8
5
5
  SHA512:
6
- metadata.gz: 962602c8cf871c1456401b48edd21e8348af1a54b851873c634ce64248bd0dbd293a798adb3bb3f3e9f62fe4778f74f3627c54bffbd8fb5aa62a920cdc0c3846
7
- data.tar.gz: df1669b0b8b3a87dce3d68d402d1e89d3abca492e66b9032bb70a2817471b6a1a64f879674c6b84a201e3f8865d62920d694229bcd65ec0dde2da4818a72a3de
6
+ metadata.gz: 5594429c88e9ba8217fbd963a7555c7003c3417dad17ed3b394b92552fb6e2e7ff49073d197ef483aa108a06baf7a6b067fc18d7e4b18d331b8f4b0d3dad0568
7
+ data.tar.gz: 53888ec183dd96d146565d2814586155cbbc76a7b3c1e25a60c2d14b9d0d41bf10c581d2bb3b87fe577ae66451d3f2a2deb2dcc378a271faf2bb462252cba9ec
@@ -128,7 +128,11 @@ class Arel::Nodes::Function
128
128
 
129
129
  alias_method(:old_as, :as) rescue nil
130
130
  def as other
131
- Arel::Nodes::As.new(self, Arel.sql(other))
131
+ res = Arel::Nodes::As.new(self.clone, Arel.sql(other))
132
+ if Gem::Version.new(Arel::VERSION) >= Gem::Version.new("9.0.0")
133
+ self.alias = Arel.sql(other)
134
+ end
135
+ res
132
136
  end
133
137
  end
134
138
 
@@ -71,7 +71,11 @@ module ArelExtensions
71
71
  end
72
72
 
73
73
  def sum opts = {unbiased: true}
74
- ArelExtensions::Nodes::Sum.new self, **opts
74
+ if Gem::Version.new(Arel::VERSION) >= Gem::Version.new("9.0.0")
75
+ Arel::Nodes::Sum.new [self]
76
+ else
77
+ ArelExtensions::Nodes::Sum.new self, **opts
78
+ end
75
79
  end
76
80
 
77
81
  # function that can be invoked to produce random numbers between 0 and 1
@@ -21,7 +21,11 @@ module ArelExtensions
21
21
  end
22
22
 
23
23
  def as other
24
- Arel::Nodes::As.new(self, Arel.sql(other))
24
+ res = Arel::Nodes::As.new(self.clone, Arel.sql(other))
25
+ if Gem::Version.new(Arel::VERSION) >= Gem::Version.new("9.0.0")
26
+ self.alias = Arel.sql(other)
27
+ end
28
+ res
25
29
  end
26
30
 
27
31
  def expr
@@ -76,7 +80,7 @@ module ArelExtensions
76
80
  when ActiveSupport::Duration
77
81
  Arel.sql(object.to_i)
78
82
  when Array
79
- Arel::Nodes::Grouping.new(object.map{|r| convert_to_node(e)})
83
+ Arel::Nodes::Grouping.new(object.map{|e| convert_to_node(e)})
80
84
  else
81
85
  raise(ArgumentError, "#{object.class} cannot be converted to CONCAT arg")
82
86
  end
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = "1.2.19".freeze
2
+ VERSION = "1.2.23".freeze
3
3
  end
@@ -2,18 +2,6 @@ module ArelExtensions
2
2
  module Visitors
3
3
  Arel::Visitors.send(:remove_const,'Oracle12') if Arel::Visitors.const_defined?('Oracle12')
4
4
  Arel::Visitors.const_set('Oracle12',Class.new(Arel::Visitors::Oracle)).class_eval do
5
- def visit_Arel_Nodes_SelectStatement(o, collector)
6
- # Oracle does not allow LIMIT clause with select for update
7
- if o.limit && o.lock
8
- raise ArgumentError, <<-MSG
9
- 'Combination of limit and lock is not supported.
10
- because generated SQL statements
11
- `SELECT FOR UPDATE and FETCH FIRST n ROWS` generates ORA-02014.`
12
- MSG
13
- end
14
-
15
- super
16
- end
17
5
 
18
6
  def visit_Arel_Nodes_SelectOptions(o, collector)
19
7
  collector = maybe_visit o.offset, collector
@@ -348,6 +348,9 @@ module ArelExtensions
348
348
  # override
349
349
  remove_method(:visit_Arel_Nodes_As) rescue nil # if Arel::Visitors::ToSql.method_defined?(:visit_Arel_Nodes_As)
350
350
  def visit_Arel_Nodes_As o, collector
351
+ if o.left.respond_to?(:alias)
352
+ o.left.alias = nil
353
+ end
351
354
  if o.left.is_a?(Arel::Nodes::Binary)
352
355
  collector << '('
353
356
  collector = visit o.left, collector
@@ -162,6 +162,12 @@ module ArelExtensions
162
162
  end
163
163
  end
164
164
 
165
+ def test_aggregation_with_ar_calculation
166
+ # Since Arel10 (Rails6.1), some unwanted behaviors on aggregated calculation were present.
167
+ # This should works no matter which version of rails is used
168
+ assert User.group(:score).average(:id).values.all?{|e| !e.nil?}
169
+ end
170
+
165
171
  # String Functions
166
172
  def test_concat
167
173
  assert_equal 'Camille Camille', t(@camille, @name + ' ' + @name)
data/version_v1.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = "1.2.19".freeze
2
+ VERSION = "1.2.23".freeze
3
3
  end
data/version_v2.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = "2.0.16".freeze
2
+ VERSION = "2.0.20".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arel_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.19
4
+ version: 1.2.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yann Azoury
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-01-07 00:00:00.000000000 Z
13
+ date: 2021-02-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: arel
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
222
  - !ruby/object:Gem::Version
223
223
  version: '0'
224
224
  requirements: []
225
- rubygems_version: 3.0.6
225
+ rubygems_version: 3.1.2
226
226
  signing_key:
227
227
  specification_version: 4
228
228
  summary: Extending Arel