arel_extensions 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/arel_extensions/version.rb +1 -1
- data/lib/arel_extensions/visitors/mssql.rb +4 -3
- data/lib/arel_extensions/visitors/mysql.rb +1 -0
- data/lib/arel_extensions/visitors/oracle.rb +1 -0
- data/lib/arel_extensions/visitors/postgresql.rb +3 -2
- data/test/with_ar/all_agnostic_test.rb +33 -0
- 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: 01beaf945929ae85c746a09b141c730414607881f7573afb31aa2fd3578ffe28
|
4
|
+
data.tar.gz: c68051e2e013ab9ce79916d6c5cbabc1f1f9a5e0cce734d71cd08c458d3f53f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdd3e7f9c03bfbe90dbd8c6ca6af65304a64446c06ea49b529483f6252249098943a96a44bc4df5cd9d6eb0ad22755be01d3f7251f953ab6bacf2f07910cedec
|
7
|
+
data.tar.gz: bc92061815cc857835eb2d5fd5a0a34b1d2688640b0dd7291802ee45ee0d6d9e6f8d2b268180ac56b723b61416677b1020f3c79cebbf376b4a3999c780e0f926
|
@@ -14,13 +14,14 @@ module ArelExtensions
|
|
14
14
|
|
15
15
|
LOADED_VISITOR::DATE_FORMAT_DIRECTIVES = {
|
16
16
|
'%Y' => 'YYYY', '%C' => '', '%y' => 'YY', '%m' => 'MM', '%B' => '', '%b' => '', '%^b' => '', # year, month
|
17
|
-
'%
|
18
|
-
'%
|
17
|
+
'%V' => 'iso_week', '%G' => '', # ISO week number and year of week
|
18
|
+
'%d' => 'DD', '%e' => '', '%j' => '', '%w' => 'dw', '%A' => '', # day, weekday
|
19
|
+
'%H' => 'hh', '%k' => '', '%I' => '', '%l' => '', '%P' => '', '%p' => '', # hours
|
19
20
|
'%M' => 'mi', '%S' => 'ss', '%L' => 'ms', '%N' => 'ns', '%z' => 'tz'
|
20
21
|
}.freeze
|
21
22
|
|
22
23
|
LOADED_VISITOR::DATE_FORMAT_FORMAT = {
|
23
|
-
'YY' => '0#', 'MM' => '0#', 'DD' => '0#', 'hh' => '0#', 'mi' => '0#', 'ss' => '0#'
|
24
|
+
'YY' => '0#', 'MM' => '0#', 'DD' => '0#', 'hh' => '0#', 'mi' => '0#', 'ss' => '0#', 'iso_week' => '0#'
|
24
25
|
}
|
25
26
|
|
26
27
|
LOADED_VISITOR::DATE_FORMAT_REGEX =
|
@@ -8,6 +8,7 @@ module ArelExtensions
|
|
8
8
|
|
9
9
|
DATE_FORMAT_DIRECTIVES = { # ISO C / POSIX
|
10
10
|
'%Y' => '%Y', '%C' => '', '%y' => '%y', '%m' => '%m', '%B' => '%M', '%b' => '%b', '%^b' => '%b', # year, month
|
11
|
+
'%V' => '%v', '%G' => '%x', # ISO week number and year of week
|
11
12
|
'%d' => '%d', '%e' => '%e', '%j' => '%j', '%w' => '%w', '%A' => '%W', # day, weekday
|
12
13
|
'%H' => '%H', '%k' => '%k', '%I' => '%I', '%l' => '%l', '%P' => '%p', '%p' => '%p', # hours
|
13
14
|
'%M' => '%i', '%S' => '%S', '%L' => '', '%N' => '%f', '%z' => ''
|
@@ -6,6 +6,7 @@ module ArelExtensions
|
|
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
8
|
'%Y' => 'YYYY', '%C' => 'CC', '%y' => 'YY', '%m' => 'MM', '%B' => 'Month', '%^B' => 'MONTH', '%b' => 'Mon', '%^b' => 'MON',
|
9
|
+
'%V' => 'IW', '%G' => 'IYYY', # ISO week number and year of week
|
9
10
|
'%d' => 'DD', '%e' => 'FMDD', '%j' => 'DDD', '%w' => '', '%A' => 'Day', # day, weekday
|
10
11
|
'%H' => 'HH24', '%k' => '', '%I' => 'HH', '%l' => '', '%P' => 'am', '%p' => 'AM', # hours
|
11
12
|
'%M' => 'MI', '%S' => 'SS', '%L' => 'MS', '%N' => 'US', '%z' => 'tz' # seconds, subseconds
|
@@ -9,9 +9,10 @@ module ArelExtensions
|
|
9
9
|
DATE_FORMAT_DIRECTIVES = {
|
10
10
|
'%Y' => 'YYYY', '%C' => 'CC', '%y' => 'YY',
|
11
11
|
'%m' => 'MM', '%B' => 'Month', '%^B' => 'MONTH', '%b' => 'Mon', '%^b' => 'MON',
|
12
|
-
'%
|
12
|
+
'%V' => 'IW', '%G' => 'IYYY', # ISO week number and year of week
|
13
|
+
'%d' => 'DD', '%e' => 'FMDD', '%j' => 'DDD', '%w' => '', '%A' => 'Day', # day, weekday
|
13
14
|
'%H' => 'HH24', '%k' => '', '%I' => 'HH', '%l' => '', '%P' => 'am', '%p' => 'AM', # hours
|
14
|
-
'%M' => 'MI', '%S' => 'SS', '%L' => 'MS', '%N' => 'US', '%z' => 'tz',
|
15
|
+
'%M' => 'MI', '%S' => 'SS', '%L' => 'MS', '%N' => 'US', '%z' => 'tz', # seconds, subseconds
|
15
16
|
'%%' => '%',
|
16
17
|
}.freeze
|
17
18
|
|
@@ -438,6 +438,39 @@ module ArelExtensions
|
|
438
438
|
end
|
439
439
|
end
|
440
440
|
|
441
|
+
def test_format_iso_week
|
442
|
+
skip "Unsupported ISO week number for DB=#{ENV['DB']}" if ['sqlite'].include?(ENV['DB'])
|
443
|
+
assert_equal '10', t(@lucas, @updated_at.format('%V'))
|
444
|
+
{
|
445
|
+
'2024-01-01 10:42:00' => '01', # Monday
|
446
|
+
'2030-01-01 10:42:00' => '01', # Tuesday
|
447
|
+
'2025-01-01 10:42:00' => '01', # Wednesday
|
448
|
+
'2026-01-01 10:42:00' => '01', # Thursday
|
449
|
+
'2027-01-01 10:42:00' => '53', # Friday
|
450
|
+
'2028-01-01 10:42:00' => '52', # Saturday
|
451
|
+
'2034-01-01 10:42:00' => '52', # Sunday
|
452
|
+
}.each do |date, exp|
|
453
|
+
assert_equal exp, t(@lucas, Arel::Nodes.build_quoted(date).cast(:datetime).format('%V'))
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
457
|
+
def test_format_iso_year_of_week
|
458
|
+
skip "Unsupported ISO year of week for DB=#{ENV['DB']}" if ['mssql', 'sqlite'].include?(ENV['DB'])
|
459
|
+
assert_equal '2014', t(@lucas, @updated_at.format('%G'))
|
460
|
+
|
461
|
+
{
|
462
|
+
'2024-01-01 10:42:00' => '2024', # Monday
|
463
|
+
'2030-01-01 10:42:00' => '2030', # Tuesday
|
464
|
+
'2025-01-01 10:42:00' => '2025', # Wednesday
|
465
|
+
'2026-01-01 10:42:00' => '2026', # Thursday
|
466
|
+
'2027-01-01 10:42:00' => '2026', # Friday
|
467
|
+
'2028-01-01 10:42:00' => '2027', # Saturday
|
468
|
+
'2034-01-01 10:42:00' => '2033', # Sunday
|
469
|
+
}.each do |date, exp|
|
470
|
+
assert_equal exp, t(@lucas, Arel::Nodes.build_quoted(date).cast(:datetime).format('%G'))
|
471
|
+
end
|
472
|
+
end
|
473
|
+
|
441
474
|
def test_coalesce
|
442
475
|
assert_equal 'Camille concat', t(@camille, @name.coalesce(nil, "default") + ' concat')
|
443
476
|
|
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: 2.1.
|
4
|
+
version: 2.1.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: 2022-03-
|
13
|
+
date: 2022-03-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|