arel_extensions 1.3.8 → 1.3.9
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/.github/workflows/publish.yml +29 -0
- data/.github/workflows/release.yml +30 -0
- data/.github/workflows/ruby.yml +0 -15
- data/NEWS.md +33 -3
- data/README.md +3 -3
- data/bin/build +15 -0
- data/bin/publish +8 -0
- data/lib/arel_extensions/version.rb +1 -1
- data/lib/arel_extensions/visitors/postgresql.rb +2 -2
- data/lib/arel_extensions.rb +20 -0
- data/test/with_ar/all_agnostic_test.rb +1 -1
- data/version_v1.rb +1 -1
- data/version_v2.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 297d1d9b84e726d164e0e001cbe2402c81f3cb1491aa15f10854e508a65d0a8b
|
4
|
+
data.tar.gz: 23697fa470d0524218097318b9f89a0d78e029e16bdeac5e23b24b6610369f6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e4bffd39e53121a46cf1aacc279747aae8e44119c6cdb3eba1e633e823ee2b3c13596f20139799be6a2ef619b7394aa1e0659569b63643bf08a8516777c84ac
|
7
|
+
data.tar.gz: 1dc5fadc6064410bff969f77ab61b52308b0c60b2a2009868a40a6055b4194440763fd82a409c9a1b05911106b863ca1cc94066d954db0faf895caa7ce5516ed
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: "Publish Gems"
|
2
|
+
on:
|
3
|
+
release:
|
4
|
+
types: [published]
|
5
|
+
|
6
|
+
jobs:
|
7
|
+
publish_gems:
|
8
|
+
name: Publish to Rubygems
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v3
|
12
|
+
- name: setup ruby 3.2
|
13
|
+
uses: ruby/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: 3.2
|
16
|
+
- name: Fetch Github Release Asset
|
17
|
+
uses: dsaltares/fetch-gh-release-asset@master
|
18
|
+
with:
|
19
|
+
file: "arel_extensions.*.gem"
|
20
|
+
regex: true
|
21
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
22
|
+
- name: List gems
|
23
|
+
run: ls -l *.gem
|
24
|
+
- name: Release Gems
|
25
|
+
uses: cadwallion/publish-rubygems-action@master
|
26
|
+
env:
|
27
|
+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
28
|
+
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
29
|
+
RELEASE_COMMAND: bin/publish
|
@@ -0,0 +1,30 @@
|
|
1
|
+
name: Release
|
2
|
+
on:
|
3
|
+
workflow_run:
|
4
|
+
workflows: ["Build and Test"]
|
5
|
+
branches: [master]
|
6
|
+
types:
|
7
|
+
- completed
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build_gems:
|
11
|
+
name: Build Gemfiles
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v3
|
15
|
+
- name: setup ruby 3.2
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: 3.2
|
19
|
+
- name: build gems
|
20
|
+
run: |
|
21
|
+
bin/build
|
22
|
+
- name: release
|
23
|
+
uses: softprops/action-gh-release@v1
|
24
|
+
with:
|
25
|
+
tag_name: ${{ github.ref }}-${{ steps.vars.outputs.sha_short }}
|
26
|
+
draft: true
|
27
|
+
files: |
|
28
|
+
./arel_extensions-*.gem
|
29
|
+
env:
|
30
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
data/.github/workflows/ruby.yml
CHANGED
@@ -49,9 +49,6 @@ jobs:
|
|
49
49
|
run: |
|
50
50
|
sudo apt-get update -q
|
51
51
|
sudo apt-get install -y freetds-dev
|
52
|
-
- name: Update system-wide gems
|
53
|
-
if: ${{ !contains(fromJson('["2.5", "jruby-9.2"]'), matrix.versions.ruby) }}
|
54
|
-
run: gem update --system --no-document
|
55
52
|
- name: Setup Gemfile for arelx 2.x
|
56
53
|
if: ${{ matrix.versions.arelx == 2 }}
|
57
54
|
run: |
|
@@ -109,9 +106,6 @@ jobs:
|
|
109
106
|
run: |
|
110
107
|
sudo apt-get update -q
|
111
108
|
sudo apt-get install -y freetds-dev
|
112
|
-
- name: Update system-wide gems
|
113
|
-
if: ${{ !contains(fromJson('["2.5", "jruby-9.2"]'), matrix.versions.ruby) }}
|
114
|
-
run: gem update --system --no-document
|
115
109
|
- name: Setup Gemfile
|
116
110
|
if: ${{ matrix.versions.arelx == 2 }}
|
117
111
|
run: |
|
@@ -191,9 +185,6 @@ jobs:
|
|
191
185
|
run: |
|
192
186
|
sudo apt-get update -q
|
193
187
|
sudo apt-get install -y freetds-dev
|
194
|
-
- name: Update system-wide gems
|
195
|
-
if: ${{ !contains(fromJson('["2.5", "jruby-9.2"]'), matrix.versions.ruby) }}
|
196
|
-
run: gem update --system --no-document
|
197
188
|
- name: Setup Gemfile
|
198
189
|
if: ${{ matrix.versions.arelx == 2 }}
|
199
190
|
run: |
|
@@ -268,9 +259,6 @@ jobs:
|
|
268
259
|
run: |
|
269
260
|
sudo apt-get update -q
|
270
261
|
sudo apt-get install -y freetds-dev
|
271
|
-
- name: Update system-wide gems
|
272
|
-
if: ${{ !contains(fromJson('["2.5", "jruby-9.2"]'), matrix.versions.ruby) }}
|
273
|
-
run: gem update --system --no-document
|
274
262
|
- name: Setup Gemfile
|
275
263
|
if: ${{ matrix.versions.arelx == 2 }}
|
276
264
|
run: |
|
@@ -337,9 +325,6 @@ jobs:
|
|
337
325
|
version: ${{ matrix.mssql }}
|
338
326
|
install: sqlengine, sqlclient, sqlpackage, localdb
|
339
327
|
sa-password: Password12!
|
340
|
-
- name: Update system-wide gems
|
341
|
-
if: ${{ !contains(fromJson('["2.5", "jruby-9.2"]'), matrix.versions.ruby) }}
|
342
|
-
run: gem update --system --no-document
|
343
328
|
- name: Setup Gemfile
|
344
329
|
if: ${{ matrix.versions.arelx == 2 }}
|
345
330
|
run: |
|
data/NEWS.md
CHANGED
@@ -1,6 +1,36 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
-
##
|
3
|
+
## Release v2.1.9/v1.3.9
|
4
|
+
|
5
|
+
### Bug Fixes
|
6
|
+
|
7
|
+
- Postgres:
|
8
|
+
- Datetime formatting in postgres now behaves like mysql: if the target
|
9
|
+
timezone is a string, we automatically consider that you're trying to
|
10
|
+
convert from `UTC`.
|
11
|
+
- Datetime casting will now automatically ask for a
|
12
|
+
`timestamp without timezone`, also aligning with the expected befavior
|
13
|
+
in mysql. This also makes casting work better with timezone conversion,
|
14
|
+
especially if you don't pass the timezone from which you're converting
|
15
|
+
to.
|
16
|
+
```ruby
|
17
|
+
scope
|
18
|
+
.select(Arel.quoted('2022-02-01 10:42:00')
|
19
|
+
.cast(:datetime)
|
20
|
+
.format_date('%Y/%m/%d %H:%M:%S', 'Europe/Paris')
|
21
|
+
.as('res'))
|
22
|
+
```
|
23
|
+
Will produce:
|
24
|
+
```sql
|
25
|
+
SELECT TO_CHAR(
|
26
|
+
CAST('2022-02-01 10:42:00' AS timestamp without time zone) AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Paris',
|
27
|
+
'YYYY/MM/DD HH24:MI:SS'
|
28
|
+
)
|
29
|
+
AS "res"
|
30
|
+
-- …
|
31
|
+
```
|
32
|
+
|
33
|
+
## Release v2.1.7/v1.3.7
|
4
34
|
|
5
35
|
### New Features
|
6
36
|
|
@@ -8,11 +38,11 @@
|
|
8
38
|
The actual behavior of `format` is inconsistent across DB vendors: in mysql we
|
9
39
|
can format dates and numbers with it, and in the other ones we only format
|
10
40
|
dates.
|
11
|
-
|
41
|
+
|
12
42
|
We're planning on normalizing this behavior. We want `format` to "cleverly"
|
13
43
|
format dates or numbers, and `format_date` / `format_number` to strictly
|
14
44
|
format dates / numbers.
|
15
|
-
|
45
|
+
|
16
46
|
The introduction of `format_date` is the first step in this direction.
|
17
47
|
|
18
48
|
## Release v2.1.6/v1.3.6
|
data/README.md
CHANGED
@@ -173,9 +173,9 @@ The second form accepts 2 kinds of values:
|
|
173
173
|
|
174
174
|
```ruby
|
175
175
|
t[:birthdate].format('%Y/%m/%d %H:%M:%S', 'posix/Pacific/Tahiti')
|
176
|
-
# => DATE_FORMAT(CONVERT_TZ(CAST(my_table.birthdate AS datetime), 'UTC', 'posix/Pacific/Tahiti'), '%Y/%m/%d %H:%i:%S')
|
177
|
-
# => TO_CHAR(CAST(my_table.birthdate AS timestamp with time zone) AT TIME ZONE 'posix/Pacific/Tahiti', 'YYYY/MM/DD HH24:MI:SS') ## PostgreSQL
|
178
|
-
# => CONVERT(datetime, my_table.birthdate) AT TIME ZONE 'UTC' AT TIME ZONE N'posix/Pacific/Tahiti'
|
176
|
+
# => DATE_FORMAT(CONVERT_TZ(CAST(my_table.birthdate AS datetime), 'UTC', 'posix/Pacific/Tahiti'), '%Y/%m/%d %H:%i:%S') ## MySQL
|
177
|
+
# => TO_CHAR(CAST(my_table.birthdate AS timestamp with time zone) AT TIME ZONE 'UTC' AT TIME ZONE 'posix/Pacific/Tahiti', 'YYYY/MM/DD HH24:MI:SS') ## PostgreSQL
|
178
|
+
# => CONVERT(datetime, my_table.birthdate) AT TIME ZONE 'UTC' AT TIME ZONE N'posix/Pacific/Tahiti' ## SQL Server (& truncated for clarity)
|
179
179
|
# ^^^^^^^^^^^^^^^^^^^^ 🚨 Invalid timezone for SQL Server. Explanation below.
|
180
180
|
```
|
181
181
|
|
data/bin/build
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#! /usr/bin/env sh
|
2
|
+
set -e
|
3
|
+
|
4
|
+
# VERSION ~> 1
|
5
|
+
echo "Packaging v1"
|
6
|
+
cp ./version_v1.rb lib/arel_extensions/version.rb
|
7
|
+
cp ./gemspecs/arel_extensions-v1.gemspec ./arel_extensions.gemspec
|
8
|
+
gem build ./arel_extensions.gemspec
|
9
|
+
|
10
|
+
# VERSION ~> 2
|
11
|
+
echo "Packaging v2"
|
12
|
+
cp ./version_v2.rb lib/arel_extensions/version.rb
|
13
|
+
cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
|
14
|
+
gem build ./arel_extensions.gemspec
|
15
|
+
|
data/bin/publish
ADDED
@@ -190,7 +190,7 @@ module ArelExtensions
|
|
190
190
|
collector << ' AT TIME ZONE '
|
191
191
|
collector = visit Arel.quoted(dst_tz), collector
|
192
192
|
when String
|
193
|
-
collector <<
|
193
|
+
collector << ") AT TIME ZONE 'UTC' AT TIME ZONE "
|
194
194
|
collector = visit Arel.quoted(o.time_zone), collector
|
195
195
|
end
|
196
196
|
collector << COMMA
|
@@ -392,7 +392,7 @@ module ArelExtensions
|
|
392
392
|
when :number, :decimal, :float
|
393
393
|
'numeric'
|
394
394
|
when :datetime
|
395
|
-
'timestamp
|
395
|
+
'timestamp without time zone'
|
396
396
|
when :date
|
397
397
|
'date'
|
398
398
|
when :binary
|
data/lib/arel_extensions.rb
CHANGED
@@ -121,6 +121,26 @@ module Arel
|
|
121
121
|
)
|
122
122
|
end
|
123
123
|
|
124
|
+
def self.json_true
|
125
|
+
res = Arel.grouping(Arel.quoted('true'))
|
126
|
+
res.instance_eval {
|
127
|
+
def return_type
|
128
|
+
:boolean
|
129
|
+
end
|
130
|
+
}
|
131
|
+
res
|
132
|
+
end
|
133
|
+
|
134
|
+
def self.json_false
|
135
|
+
res = Arel.grouping(Arel.quoted('false'))
|
136
|
+
res.instance_eval {
|
137
|
+
def return_type
|
138
|
+
:boolean
|
139
|
+
end
|
140
|
+
}
|
141
|
+
res
|
142
|
+
end
|
143
|
+
|
124
144
|
# The NULL literal.
|
125
145
|
def self.null
|
126
146
|
Arel.quoted(nil)
|
@@ -501,7 +501,7 @@ module ArelExtensions
|
|
501
501
|
#
|
502
502
|
# MySQL is happy to consider that times by default are in UTC.
|
503
503
|
assert_equal '2014/03/03 13:42:00', t(@lucas, @updated_at.send(method, '%Y/%m/%d %H:%M:%S', {tz['utc'] => tz['paris']}))
|
504
|
-
refute_equal '2014/03/03 13:42:00', t(@lucas, @updated_at.send(method, '%Y/%m/%d %H:%M:%S', tz['paris'])) if
|
504
|
+
refute_equal '2014/03/03 13:42:00', t(@lucas, @updated_at.send(method, '%Y/%m/%d %H:%M:%S', tz['paris'])) if !%w[mysql postgresql].include?(ENV['DB'])
|
505
505
|
|
506
506
|
# Winter/Summer time
|
507
507
|
assert_equal '2014/08/03 14:42:00', t(@lucas, (@updated_at + 5.months).send(method, '%Y/%m/%d %H:%M:%S', {tz['utc'] => tz['paris']}))
|
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.3.
|
4
|
+
version: 1.3.9
|
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:
|
13
|
+
date: 2024-05-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: arel
|
@@ -67,6 +67,8 @@ extra_rdoc_files:
|
|
67
67
|
- functions.html
|
68
68
|
files:
|
69
69
|
- ".codeclimate.yml"
|
70
|
+
- ".github/workflows/publish.yml"
|
71
|
+
- ".github/workflows/release.yml"
|
70
72
|
- ".github/workflows/ruby.yml"
|
71
73
|
- ".gitignore"
|
72
74
|
- ".rubocop.yml"
|
@@ -79,6 +81,8 @@ files:
|
|
79
81
|
- TODO
|
80
82
|
- appveyor.yml
|
81
83
|
- arel_extensions.gemspec
|
84
|
+
- bin/build
|
85
|
+
- bin/publish
|
82
86
|
- dev/compose.yaml
|
83
87
|
- functions.html
|
84
88
|
- gemfiles/rails3.gemfile
|
@@ -210,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
214
|
- !ruby/object:Gem::Version
|
211
215
|
version: '0'
|
212
216
|
requirements: []
|
213
|
-
rubygems_version: 3.
|
217
|
+
rubygems_version: 3.4.19
|
214
218
|
signing_key:
|
215
219
|
specification_version: 4
|
216
220
|
summary: Extending Arel
|