arel_extensions 1.5.2 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/publish.yml +2 -1
- data/.github/workflows/ruby.yml +2 -2
- data/NEWS.md +5 -0
- data/gemfiles/rails6.gemfile +1 -0
- data/gemfiles/rails6_1.gemfile +1 -0
- data/gemfiles/rails7.gemfile +1 -0
- data/gemfiles/rails7_1.gemfile +0 -1
- data/init/postgresql.sql +3 -4
- data/lib/arel_extensions/comparators.rb +2 -0
- data/lib/arel_extensions/string_functions.rb +4 -1
- data/lib/arel_extensions/version.rb +1 -1
- data/test/visitors/test_to_sql.rb +1 -1
- data/test/with_ar/all_agnostic_test.rb +11 -1
- data/version_v1.rb +1 -1
- data/version_v2.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: 63ac168e55da77eacb9edfa70f025558721346a4912f225a2b35be1b7bd4eb66
|
4
|
+
data.tar.gz: d24d852a75734d25306326ce3068ad541155f2643990e71eeedccbe823354d2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae560399c811449f49ad80139a244e2e8602b0e897b17ec2a58e0af3e99aa31e6e4c302fd78a32737817b03531bc86f4cfd3b929e149c2fa862af371a10b6b2a
|
7
|
+
data.tar.gz: 581b12e386fc04cc4fd0dd7e7ab975a40ec6f077203f9d8350b665e7f679c8bd942ab2b30c4f6225cc3bb85dc1213247743e497e059bae83fe56d541235a8eb8
|
data/.github/workflows/ruby.yml
CHANGED
@@ -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.
|
data/gemfiles/rails6.gemfile
CHANGED
@@ -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'
|
data/gemfiles/rails6_1.gemfile
CHANGED
@@ -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'
|
data/gemfiles/rails7.gemfile
CHANGED
@@ -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'
|
data/gemfiles/rails7_1.gemfile
CHANGED
@@ -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
|
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((
|
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 $$
|
@@ -21,7 +21,10 @@ module ArelExtensions
|
|
21
21
|
module StringFunctions
|
22
22
|
# *FindInSet function .......
|
23
23
|
def &(other)
|
24
|
-
ArelExtensions::Nodes::FindInSet.new [
|
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.
|
@@ -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
data/version_v2.rb
CHANGED
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.5.
|
4
|
+
version: 1.5.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-
|
13
|
+
date: 2025-02-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: arel
|