arel_extensions 1.2.23 → 1.2.25

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: dd9036278df59b6ea574de919e8c2ad7a4326aa40466b00f84be093d8352e591
4
- data.tar.gz: d3cca86041854d9d1dcc940782719d95f21c26d02f6afc8cb6442a4173bf40b8
3
+ metadata.gz: 006465d41dbb691f2048bd0ffc2aaf3d2f1f48f508955f50774ee9c0413ccfa5
4
+ data.tar.gz: 47c61ff636e5fd8c4eb0f470facd661406c4bdca590037a1af5ba87e02ca415e
5
5
  SHA512:
6
- metadata.gz: 5594429c88e9ba8217fbd963a7555c7003c3417dad17ed3b394b92552fb6e2e7ff49073d197ef483aa108a06baf7a6b067fc18d7e4b18d331b8f4b0d3dad0568
7
- data.tar.gz: 53888ec183dd96d146565d2814586155cbbc76a7b3c1e25a60c2d14b9d0d41bf10c581d2bb3b87fe577ae66451d3f2a2deb2dcc378a271faf2bb462252cba9ec
6
+ metadata.gz: f6fb93194f8d9841380ba59e1fd72e0afa8bc0c84809d44e6af6b1282ce04bf1933900aafa6715cbdbf074cd6ba0585698aadc1678c80c1cbfdacc85a04472c3
7
+ data.tar.gz: a4ac1afdba08edb577f182e9e7d7236a5f87ce741ef63979b95c24ac2562fee76576964dc3b58c54a052952046e51c2ae5a9225d2b91c830eecba3c3b372da52
@@ -33,6 +33,12 @@ class Arel::Nodes::Grouping
33
33
  include Arel::OrderPredications
34
34
  end
35
35
 
36
+ class Arel::Nodes::Ordering
37
+ def eql? other
38
+ self.hash.eql? other.hash
39
+ end
40
+ end
41
+
36
42
  class Arel::Nodes::Function
37
43
  include Arel::Math
38
44
  include Arel::Expressions
@@ -152,6 +158,9 @@ class Arel::Nodes::Unary
152
158
  include ArelExtensions::MathFunctions
153
159
  include ArelExtensions::Comparators
154
160
  include ArelExtensions::Predications
161
+ def eql? other
162
+ hash == other.hash
163
+ end
155
164
  end
156
165
 
157
166
  class Arel::Nodes::Binary
@@ -161,6 +170,9 @@ class Arel::Nodes::Binary
161
170
  include ArelExtensions::Comparators
162
171
  include ArelExtensions::BooleanFunctions
163
172
  include ArelExtensions::Predications
173
+ def eql? other
174
+ hash == other.hash
175
+ end
164
176
  end
165
177
 
166
178
  class Arel::Nodes::Equality
@@ -2,6 +2,12 @@ module ArelExtensions
2
2
  module Nodes
3
3
  class Length < Function
4
4
  RETURN_TYPE = :integer
5
+ attr_accessor :bytewise
6
+
7
+ def initialize(node, bytewise = true)
8
+ @bytewise = bytewise
9
+ super([node])
10
+ end
5
11
  end
6
12
  end
7
13
  end
@@ -24,9 +24,17 @@ module ArelExtensions
24
24
  ArelExtensions::Nodes::FindInSet.new [other, self]
25
25
  end
26
26
 
27
- # LENGTH function returns the length of the value in a text field.
27
+ # LENGTH function returns the length (bytewise) of the value in a text field.
28
28
  def length
29
- ArelExtensions::Nodes::Length.new [self]
29
+ ArelExtensions::Nodes::Length.new self, true
30
+ end
31
+
32
+ def byte_length
33
+ ArelExtensions::Nodes::Length.new self, true
34
+ end
35
+
36
+ def char_length
37
+ ArelExtensions::Nodes::Length.new self, false
30
38
  end
31
39
 
32
40
  # LOCATE function returns the first starting position of a string in another string.
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = "1.2.23".freeze
2
+ VERSION = "1.2.25".freeze
3
3
  end
@@ -155,7 +155,7 @@ module ArelExtensions
155
155
  end
156
156
 
157
157
  def visit_ArelExtensions_Nodes_Length o, collector
158
- collector << "LEN("
158
+ collector << "#{o.bytewise ? 'DATALENGTH' : 'LEN'}("
159
159
  collector = visit o.expr, collector
160
160
  collector << ")"
161
161
  collector
@@ -5,7 +5,7 @@ module ArelExtensions
5
5
  SPECIAL_CHARS = {"\t" => 'CHR(9)', "\n" => 'CHR(10)', "\r" => 'CHR(13)'}
6
6
  DATE_MAPPING = {'d' => 'DAY', 'm' => 'MONTH', 'w' => 'IW', 'y' => 'YEAR', 'wd' => 'D', 'h' => 'HOUR', 'mn' => 'MINUTE', 's' => 'SECOND'}
7
7
  DATE_FORMAT_DIRECTIVES = {
8
- '%Y' => 'IYYY', '%C' => 'CC', '%y' => 'YY', '%m' => 'MM', '%B' => 'Month', '%^B' => 'MONTH', '%b' => 'Mon', '%^b' => 'MON',
8
+ '%Y' => 'YYYY', '%C' => 'CC', '%y' => 'YY', '%m' => 'MM', '%B' => 'Month', '%^B' => 'MONTH', '%b' => 'Mon', '%^b' => 'MON',
9
9
  '%d' => 'DD', '%e' => 'FMDD', '%j' => 'DDD', '%w' => '', '%A' => 'Day', # day, weekday
10
10
  '%H' => 'HH24', '%k' => '', '%I' => 'HH', '%l' => '', '%P' => 'am', '%p' => 'AM', # hours
11
11
  '%M' => 'MI', '%S' => 'SS', '%L' => 'MS', '%N' => 'US', '%z' => 'tz' # seconds, subseconds
@@ -308,7 +308,7 @@ module ArelExtensions
308
308
  end
309
309
 
310
310
  def visit_ArelExtensions_Nodes_Length o, collector
311
- collector << "LENGTH("
311
+ collector << "LENGTH#{o.bytewise ? 'B' : ''}("
312
312
  collector = visit o.expr, collector
313
313
  collector << ")"
314
314
  collector
@@ -7,7 +7,7 @@ module ArelExtensions
7
7
  }.freeze
8
8
 
9
9
  DATE_FORMAT_DIRECTIVES = {
10
- '%Y' => 'IYYY', '%C' => 'CC', '%y' => 'YY',
10
+ '%Y' => 'YYYY', '%C' => 'CC', '%y' => 'YY',
11
11
  '%m' => 'MM', '%B' => 'Month', '%^B' => 'MONTH', '%b' => 'Mon', '%^b' => 'MON',
12
12
  '%d' => 'DD', '%e' => 'FMDD', '%j' => 'DDD', '%w' => '', '%A' => 'Day', # day, weekday
13
13
  '%H' => 'HH24', '%k' => '', '%I' => 'HH', '%l' => '', '%P' => 'am', '%p' => 'AM', # hours
@@ -117,7 +117,7 @@ module ArelExtensions
117
117
  end
118
118
 
119
119
  def visit_ArelExtensions_Nodes_Length o, collector
120
- collector << "LENGTH("
120
+ collector << "#{o.bytewise ? '' : 'CHAR_'}LENGTH("
121
121
  collector = visit o.left, collector
122
122
  collector << ")"
123
123
  collector
data/version_v1.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = "1.2.23".freeze
2
+ VERSION = "1.2.25".freeze
3
3
  end
data/version_v2.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = "2.0.20".freeze
2
+ VERSION = "2.0.22".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.23
4
+ version: 1.2.25
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-02-04 00:00:00.000000000 Z
13
+ date: 2021-04-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: arel