arel_extensions 2.3.2 → 2.3.3

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: 897fdf4d5248e3a7d67d5c99bdea4341e0f3d29f756d712bb982577adc438671
4
- data.tar.gz: 5066e14f35d9f820e413ed8cbb994fd8870966b9b086536c57e71a0718a60033
3
+ metadata.gz: 2117a2b819da1a1699428d490c507dbd426fae75cfe135c07dc77dd92889fe64
4
+ data.tar.gz: c822dbd22779954cccd01a0915c2ccd88340d7dca8e44fc4883036268f154947
5
5
  SHA512:
6
- metadata.gz: 7cc535755cbe7274d118a8b4ab68321082664be5c8714e44f546c71f16ebe083a54acd816c720b5d3e8dde4272c649565b544e94072e5d9de50be1625f26888f
7
- data.tar.gz: d8d578ed26702eb285fe2e36cd4b9166187ed3486eccd09901b9f599750d0e45a6100e09394fdb1181e2c64c3446ef00dae89b2ef18d1dba17321b17a0b0b39b
6
+ metadata.gz: a003802df5fa1bf4ed39562f679deeb3675f9771d14693a740a0374631e311a7ba25d6418f8161b1042e413ab7a71b3b283757b20d903ba0061734d12a14481c
7
+ data.tar.gz: 413005a75a63ff2a6e6c72e75ccff060b2c6d3698725a561541b3b981400a48f1840fb1d762f02fd07b453df2107acbefe465a75e5e07c4503d458d444381e8f
@@ -1,7 +1,8 @@
1
- name: "Publish Gems"
1
+ name: rubygems.org
2
2
  on:
3
3
  release:
4
4
  types: [published]
5
+ workflow_dispatch:
5
6
 
6
7
  jobs:
7
8
  publish_gems:
@@ -356,8 +356,8 @@ jobs:
356
356
  # {ruby: jruby-9.3, rails: 6_1, arelx: 2},
357
357
  # {ruby: jruby-9.3, rails: 6, arelx: 2},
358
358
  # {ruby: jruby-9.3, rails: 5_2, arelx: 1},
359
- { ruby: jruby-9.4, rails: 7_1, arelx: 2 },
360
- { ruby: jruby-9.4, rails: 7, arelx: 2 },
359
+ { ruby: jruby-9.4.10, rails: 7_1, arelx: 2 }, # The reason we pin to the patch level is https://github.com/ruby/psych/issues/700
360
+ { ruby: jruby-9.4.10, rails: 7, arelx: 2 },
361
361
  #
362
362
  # 6 and 6.1 don't work because of a bug in the alt adapter
363
363
  # https://github.com/JesseChavez/activerecord-jdbc-adapter/issues/16
data/NEWS.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## [unreleased]
4
4
 
5
+ ## Release v2.3.3/v1.5.3 (11-02-2025)
6
+
7
+ - Fix the `&` operator which does `find_in_set` for mysql and postgres, accepting strings and integers.
8
+ - Add `regex_matches`, an alias for `=~`.
9
+
5
10
  ## Release v2.3.2/v1.5.2 (02-01-2025)
6
11
 
7
12
  - Fix a subtle bug on table access as in `table[:col]` in certain situations.
@@ -5,6 +5,7 @@ gem 'rails', '~> 6.0.0'
5
5
  group :development, :test do
6
6
  gem 'ruby-lsp', platforms: %i[mri]
7
7
  gem 'debug', platforms: %i[mri]
8
+ gem 'concurrent-ruby', '1.3.4' # Need to pin b/c of a known issue https://github.com/rails/rails/issues/54260
8
9
 
9
10
  gem 'activesupport', '~> 6.0.0'
10
11
  gem 'activemodel', '~> 6.0.0'
@@ -5,6 +5,7 @@ gem 'rails', '~> 6.1.0'
5
5
  group :development, :test do
6
6
  gem 'ruby-lsp', platforms: %i[mri]
7
7
  gem 'debug', platforms: %i[mri]
8
+ gem 'concurrent-ruby', '1.3.4' # Need to pin b/c of a known issue https://github.com/rails/rails/issues/54260
8
9
 
9
10
  gem 'activesupport', '~> 6.1.0'
10
11
  gem 'activemodel', '~> 6.1.0'
@@ -5,6 +5,7 @@ gem 'rails', '~> 7.0.1'
5
5
  group :development, :test do
6
6
  gem 'ruby-lsp', platforms: %i[mri]
7
7
  gem 'debug', platforms: %i[mri]
8
+ gem 'concurrent-ruby', '1.3.4' # Need to pin b/c of a known issue https://github.com/rails/rails/issues/54260
8
9
 
9
10
  gem 'activesupport', '~> 7.0.1'
10
11
  gem 'activemodel', '~> 7.0.1'
@@ -22,7 +22,6 @@ group :development, :test do
22
22
  gem 'activerecord-oracle_enhanced-adapter', '~> 7.0.0' if ENV.has_key? 'ORACLE_HOME'
23
23
 
24
24
  # for JRuby
25
- gem 'jar-dependencies', '0.4.1', platforms: :jruby
26
25
  gem 'jdbc-mssql', platforms: :jruby, require: true
27
26
  gem 'jdbc-sqlite3', platform: :jruby
28
27
  gem 'activerecord-jdbc-alt-adapter', '~> 71.0.0.alpha1', platform: :jruby, require: true
data/init/postgresql.sql CHANGED
@@ -1,18 +1,17 @@
1
- CREATE OR REPLACE FUNCTION public.find_in_set(n INTEGER, s TEXT)
1
+ CREATE OR REPLACE FUNCTION public.find_in_set(n TEXT, s TEXT)
2
2
  RETURNS INT4
3
3
  LANGUAGE sql
4
4
  AS $function$
5
5
  SELECT * FROM (
6
6
  select int4(z.row_number) from (
7
7
  select row_number() over(), y.x
8
- from (select unnest(('{' || $2 || '}')::int[]) as x) as y
8
+ from (select unnest(regexp_split_to_array($2, ',')) as x) as y -- use string_to_array if on pg 14+.
9
9
  ) as z
10
10
  where z.x = $1
11
11
  UNION ALL
12
12
  SELECT 0) z
13
13
  LIMIT 1
14
- $function$
15
- ;
14
+ $function$;
16
15
 
17
16
  CREATE OR REPLACE FUNCTION public.levenshtein_distance(s text, t text)
18
17
  RETURNS integer AS $$
@@ -25,6 +25,8 @@ module ArelExtensions
25
25
  # end
26
26
  end
27
27
 
28
+ alias regex_matches =~
29
+
28
30
  # NOT_REGEXP function
29
31
  # Negation of Regexp
30
32
  def !~(other)
@@ -21,7 +21,10 @@ module ArelExtensions
21
21
  module StringFunctions
22
22
  # *FindInSet function .......
23
23
  def &(other)
24
- ArelExtensions::Nodes::FindInSet.new [other, self]
24
+ ArelExtensions::Nodes::FindInSet.new [
25
+ Arel.quoted(other.is_a?(Integer) ? other.to_s : other),
26
+ self,
27
+ ]
25
28
  end
26
29
 
27
30
  # LENGTH function returns the length (bytewise) of the value in a text field.
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = '2.3.2'.freeze
2
+ VERSION = '2.3.3'.freeze
3
3
  end
@@ -115,7 +115,7 @@ module ArelExtensions
115
115
  # puts (c.length.round + 42).inspect
116
116
  _(compile(c.length.round + 42)).must_be_like %{(ROUND(LENGTH("users"."name")) + 42)}
117
117
  _(compile(c.locate('test'))).must_be_like %{LOCATE('test', "users"."name")}
118
- _(compile(c & 42)).must_be_like %{FIND_IN_SET(42, "users"."name")}
118
+ _(compile(c & 42)).must_be_like %{FIND_IN_SET('42', "users"."name")}
119
119
 
120
120
  _(compile((c >= 'test').as('new_name'))).must_be_like %{("users"."name" >= 'test') AS new_name}
121
121
  _(compile(c <= @table[:comments])).must_be_like %{"users"."name" <= "users"."comments"}
@@ -68,7 +68,7 @@ module ArelExtensions
68
68
  @laure = User.where(id: u.id)
69
69
  u = User.create age: nil, name: 'Test', created_at: d, score: 1.62, other: 'toto'
70
70
  @test = User.where(id: u.id)
71
- u = User.create age: -42, name: 'Negatif', comments: '1,22,3,42,2', created_at: d, updated_at: d.to_time, score: 0.17
71
+ u = User.create age: -42, name: 'Negatif', comments: '1,22,3,42,2', created_at: d, updated_at: d.to_time, score: 0.17, other: '2'
72
72
  @neg = User.where(id: u.id)
73
73
  u = User.create age: 15, name: 'Justin', created_at: d, score: 11.0
74
74
  @justin = User.where(id: u.id)
@@ -297,6 +297,9 @@ module ArelExtensions
297
297
  skip 'SQL Server does not know about FIND_IN_SET' if @env_db == 'mssql'
298
298
  assert_equal 5, t(@neg, @comments & 2)
299
299
  assert_equal 0, t(@neg, @comments & 6) # not found
300
+ assert_equal 5, t(@neg, @comments & '2')
301
+ assert_equal 0, t(@neg, @comments & '6') # not found
302
+ assert_equal 5, t(@neg, @comments & @other)
300
303
  end
301
304
 
302
305
  def test_string_comparators
@@ -343,6 +346,13 @@ module ArelExtensions
343
346
  assert_equal 8, User.where(@name !~ /^L/).count
344
347
  end
345
348
 
349
+ def test_regex_matches
350
+ skip "Sqlite version can't load extension for regexp" if $sqlite && $load_extension_disabled
351
+ skip 'SQL Server does not know about REGEXP without extensions' if @env_db == 'mssql'
352
+ assert_equal 1, User.where(@name.regex_matches '^M').count
353
+ assert_equal 1, User.where(@name.regex_matches /^M/).count
354
+ end
355
+
346
356
  def test_imatches
347
357
  # puts User.where(@name.imatches('m%')).to_sql
348
358
  assert_equal 1, User.where(@name.imatches('m%')).count
data/version_v1.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = '1.5.2'.freeze
2
+ VERSION = '1.5.3'.freeze
3
3
  end
data/version_v2.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = '2.3.2'.freeze
2
+ VERSION = '2.3.3'.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: 2.3.2
4
+ version: 2.3.3
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: 2025-01-04 00:00:00.000000000 Z
13
+ date: 2025-02-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord