arel_extensions 1.2.18 → 1.2.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +102 -0
- data/arel_extensions.gemspec +2 -2
- data/gemfiles/rails6.gemfile +3 -3
- data/gemfiles/rails6_1.gemfile +30 -0
- data/gemspecs/arel_extensions-v1.gemspec +28 -0
- data/{gemspec_v2 → gemspecs}/arel_extensions-v2.gemspec +0 -0
- data/generate_gems.sh +4 -3
- data/lib/arel_extensions.rb +4 -2
- data/lib/arel_extensions/math_functions.rb +3 -3
- data/lib/arel_extensions/nodes/concat.rb +1 -1
- data/lib/arel_extensions/nodes/std.rb +4 -4
- data/lib/arel_extensions/version.rb +1 -1
- data/lib/arel_extensions/visitors/to_sql.rb +12 -3
- data/test/database.yml +2 -0
- data/version_v1.rb +1 -1
- data/version_v2.rb +1 -1
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b1349341148022d22f5f1db49226c8279bfc9474e48dfbeed4741f68dedc1bc
|
4
|
+
data.tar.gz: 8ef43ffbefa6e47f95bde8e9212b195e877cd97700ec113cb0a394fd0eff8014
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 962602c8cf871c1456401b48edd21e8348af1a54b851873c634ce64248bd0dbd293a798adb3bb3f3e9f62fe4778f74f3627c54bffbd8fb5aa62a920cdc0c3846
|
7
|
+
data.tar.gz: df1669b0b8b3a87dce3d68d402d1e89d3abca492e66b9032bb70a2817471b6a1a64f879674c6b84a201e3f8865d62920d694229bcd65ec0dde2da4818a72a3de
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
|
21
|
+
services:
|
22
|
+
postgres:
|
23
|
+
image: postgres:11.6-alpine
|
24
|
+
env:
|
25
|
+
POSTGRES_DB: arext_test
|
26
|
+
ports:
|
27
|
+
- 5432:5432
|
28
|
+
# needed because the postgres container does not provide a healthcheck
|
29
|
+
options: >-
|
30
|
+
--health-cmd "pg_isready -d arext_test -U postgres -p 5432"
|
31
|
+
--health-interval 10s
|
32
|
+
--health-timeout 5s
|
33
|
+
--health-retries 5
|
34
|
+
mysql:
|
35
|
+
image: mysql:5.7
|
36
|
+
env:
|
37
|
+
MYSQL_ALLOW_EMPTY_PASSWORD: true
|
38
|
+
MYSQL_USERNAME: travis
|
39
|
+
MYSQL_DATABASE: arext_test
|
40
|
+
ports:
|
41
|
+
- 3306:3306
|
42
|
+
options: >-
|
43
|
+
--health-cmd="mysqladmin ping"
|
44
|
+
--health-interval=10s
|
45
|
+
--health-timeout=5s
|
46
|
+
--health-retries=3
|
47
|
+
|
48
|
+
strategy:
|
49
|
+
matrix:
|
50
|
+
ruby-version:
|
51
|
+
- 3.0.0-preview1
|
52
|
+
- 2.7
|
53
|
+
- 2.5
|
54
|
+
- 2.3
|
55
|
+
rails-version:
|
56
|
+
- 6_1
|
57
|
+
- 6
|
58
|
+
- 5_2
|
59
|
+
exclude:
|
60
|
+
- ruby-version: 2.3
|
61
|
+
rails-version: 6_1
|
62
|
+
- ruby-version: 2.3
|
63
|
+
rails-version: 6
|
64
|
+
- ruby-version: 3.0.0-preview1
|
65
|
+
rails-version: 5.2
|
66
|
+
continue-on-error: ${{ true }}
|
67
|
+
|
68
|
+
steps:
|
69
|
+
- uses: actions/checkout@v2
|
70
|
+
- name: Set up Ruby
|
71
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
72
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
73
|
+
# uses: ruby/setup-ruby@v1
|
74
|
+
uses: ruby/setup-ruby@21351ecc0a7c196081abca5dc55b08f085efe09a
|
75
|
+
with:
|
76
|
+
ruby-version: ${{ matrix.ruby-version }}
|
77
|
+
- name: Setup gemspec
|
78
|
+
if: ${{ matrix.rails-version == '6_1' || matrix.rails-version == '6' }}
|
79
|
+
run: cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
|
80
|
+
- name: Install dependencies
|
81
|
+
run: |
|
82
|
+
export BUNDLE_GEMFILE=gemfiles/rails${{ matrix.rails-version }}.gemfile
|
83
|
+
bundle install
|
84
|
+
- name: Run test to_sql
|
85
|
+
run: rake test:to_sql
|
86
|
+
- name: Run test Postgres
|
87
|
+
env:
|
88
|
+
PGHOST: localhost
|
89
|
+
PGUSER: postgres
|
90
|
+
run: rake test:postgresql
|
91
|
+
- name: Run test MySql
|
92
|
+
env:
|
93
|
+
DB_CONNECTION: mysql
|
94
|
+
DB_HOST: 127.0.0.1
|
95
|
+
DB_PORT: 3306
|
96
|
+
DB_DATABASE: arext_test
|
97
|
+
DB_USERNAME: travis
|
98
|
+
run: |
|
99
|
+
sudo apt-get install -y mysql-client
|
100
|
+
mysql --host 127.0.0.1 --port 3306 -uroot -e 'create user travis;'
|
101
|
+
mysql --host 127.0.0.1 --port 3306 -uroot -e 'GRANT ALL PRIVILEGES ON arext_test.* TO travis;'
|
102
|
+
rake test:mysql
|
data/arel_extensions.gemspec
CHANGED
@@ -20,9 +20,9 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
|
23
|
-
s.add_dependency('
|
23
|
+
s.add_dependency('arel', '>= 6.0')
|
24
24
|
|
25
25
|
s.add_development_dependency('minitest', '~> 5.9')
|
26
26
|
s.add_development_dependency('rdoc', '~> 4.0')
|
27
27
|
s.add_development_dependency('rake', '~> 12.3.3')
|
28
|
-
end
|
28
|
+
end
|
data/gemfiles/rails6.gemfile
CHANGED
@@ -12,8 +12,8 @@ group :development, :test do
|
|
12
12
|
gem "mysql2", '0.5.2', platforms: [:mri, :mswin, :mingw]
|
13
13
|
gem "pg",'< 1.0.0', platforms: [:mri, :mingw]
|
14
14
|
|
15
|
-
gem "tiny_tds", platforms: [:mri, :mingw] if RUBY_PLATFORM =~ /windows/
|
16
|
-
gem "activerecord-sqlserver-adapter", platforms: [:mri, :mingw]
|
15
|
+
#gem "tiny_tds", platforms: [:mri, :mingw] if RUBY_PLATFORM =~ /windows/
|
16
|
+
#gem "activerecord-sqlserver-adapter", platforms: [:mri, :mingw]
|
17
17
|
|
18
18
|
gem 'ruby-oci8', platforms: [:mri, :mswin, :mingw] if ENV.has_key? 'ORACLE_HOME'
|
19
19
|
gem 'activerecord-oracle_enhanced-adapter', '~> 6.0.0' if ENV.has_key? 'ORACLE_HOME'
|
@@ -27,4 +27,4 @@ group :development, :test do
|
|
27
27
|
gem "activerecord-jdbcmssql-adapter", platforms: :jruby
|
28
28
|
end
|
29
29
|
|
30
|
-
gemspec path: "../
|
30
|
+
gemspec path: "../"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gem 'rails', '~> 6.1.0'
|
4
|
+
|
5
|
+
|
6
|
+
group :development, :test do
|
7
|
+
gem 'activesupport', '~> 6.1.0'
|
8
|
+
gem 'activemodel', '~> 6.1.0'
|
9
|
+
gem 'activerecord', '~> 6.1.0'
|
10
|
+
|
11
|
+
gem "sqlite3", '~> 1.4', platforms: [:mri, :mswin, :mingw]
|
12
|
+
gem "mysql2", '0.5.2', platforms: [:mri, :mswin, :mingw]
|
13
|
+
gem "pg",'~> 1.1', platforms: [:mri, :mingw]
|
14
|
+
|
15
|
+
#gem "tiny_tds", platforms: [:mri, :mingw] if RUBY_PLATFORM =~ /windows/
|
16
|
+
#gem "activerecord-sqlserver-adapter", platforms: [:mri, :mingw]
|
17
|
+
|
18
|
+
gem 'ruby-oci8', platforms: [:mri, :mswin, :mingw] if ENV.has_key? 'ORACLE_HOME'
|
19
|
+
gem 'activerecord-oracle_enhanced-adapter', '~> 6.0.0' if ENV.has_key? 'ORACLE_HOME'
|
20
|
+
|
21
|
+
# for JRuby
|
22
|
+
gem 'activerecord-jdbc-adapter', platforms: :jruby
|
23
|
+
gem "jdbc-sqlite3", platforms: :jruby
|
24
|
+
gem "activerecord-jdbcsqlite3-adapter", platforms: :jruby
|
25
|
+
gem "activerecord-jdbcmysql-adapter", platforms: :jruby
|
26
|
+
gem "activerecord-jdbcpostgresql-adapter", platforms: :jruby
|
27
|
+
gem "activerecord-jdbcmssql-adapter", platforms: :jruby
|
28
|
+
end
|
29
|
+
|
30
|
+
gemspec path: "../"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "arel_extensions/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "arel_extensions"
|
6
|
+
s.version = ArelExtensions::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Yann Azoury", "Félix Bellanger", "Julien Delporte"]
|
9
|
+
s.email = ["yann.azoury@faveod.com", "felix.bellanger@faveod.com", "julien.delporte@faveod.com"]
|
10
|
+
s.homepage = "https://github.com/Faveod/arel-extensions"
|
11
|
+
s.description = "Adds new features to Arel"
|
12
|
+
s.summary = "Extending Arel"
|
13
|
+
s.license = 'MIT'
|
14
|
+
|
15
|
+
s.rdoc_options = ["--main", "README.md"]
|
16
|
+
s.extra_rdoc_files = ["MIT-LICENSE.txt", "README.md", 'functions.html']
|
17
|
+
|
18
|
+
# Manifest
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
s.add_dependency('arel', '>= 6.0')
|
24
|
+
|
25
|
+
s.add_development_dependency('minitest', '~> 5.9')
|
26
|
+
s.add_development_dependency('rdoc', '~> 4.0')
|
27
|
+
s.add_development_dependency('rake', '~> 12.3.3')
|
28
|
+
end
|
File without changes
|
data/generate_gems.sh
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
|
2
|
-
gem uninstall arel_extensions
|
2
|
+
#gem uninstall arel_extensions
|
3
3
|
|
4
4
|
# VERSION ~> 1
|
5
5
|
cp ./version_v1.rb lib/arel_extensions/version.rb
|
6
|
+
cp ./gemspecs/arel_extensions-v1.gemspec ./arel_extensions.gemspec
|
6
7
|
gem build ./arel_extensions.gemspec
|
7
8
|
|
8
9
|
# VERSION ~> 2
|
9
10
|
cp ./version_v2.rb lib/arel_extensions/version.rb
|
10
11
|
mv ./arel_extensions.gemspec ./arel_extensions.gemspec.bck
|
11
|
-
cp ./
|
12
|
+
cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
|
12
13
|
gem build ./arel_extensions.gemspec
|
13
14
|
cp ./version_v1.rb lib/arel_extensions/version.rb
|
14
|
-
cp ./arel_extensions.gemspec
|
15
|
+
cp ./gemspecs/arel_extensions-v1.gemspec ./arel_extensions.gemspec
|
data/lib/arel_extensions.rb
CHANGED
@@ -16,8 +16,10 @@ class Arel::Nodes::Casted
|
|
16
16
|
include Arel::AliasPredication
|
17
17
|
|
18
18
|
# They forget to define hash.
|
19
|
-
|
20
|
-
|
19
|
+
if Gem::Version.new(Arel::VERSION) < Gem::Version.new("10.0.0")
|
20
|
+
def hash
|
21
|
+
[self.class, self.val, self.attribute].hash
|
22
|
+
end
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
@@ -63,15 +63,15 @@ module ArelExtensions
|
|
63
63
|
|
64
64
|
# Aggregate Functions
|
65
65
|
def std opts = {unbiased: true}
|
66
|
-
ArelExtensions::Nodes::Std.new self, opts
|
66
|
+
ArelExtensions::Nodes::Std.new self, **opts
|
67
67
|
end
|
68
68
|
|
69
69
|
def variance opts = {unbiased: true}
|
70
|
-
ArelExtensions::Nodes::Variance.new self, opts
|
70
|
+
ArelExtensions::Nodes::Variance.new self, **opts
|
71
71
|
end
|
72
72
|
|
73
73
|
def sum opts = {unbiased: true}
|
74
|
-
ArelExtensions::Nodes::Sum.new self, opts
|
74
|
+
ArelExtensions::Nodes::Sum.new self, **opts
|
75
75
|
end
|
76
76
|
|
77
77
|
# function that can be invoked to produce random numbers between 0 and 1
|
@@ -4,9 +4,9 @@ module ArelExtensions
|
|
4
4
|
RETURN_TYPE = :number
|
5
5
|
attr_accessor :unbiased_estimator
|
6
6
|
|
7
|
-
def initialize node, opts
|
7
|
+
def initialize node, **opts
|
8
8
|
@unbiased_estimator = opts[:unbiased] ? true : false
|
9
|
-
super node, opts
|
9
|
+
super node, **opts
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -14,9 +14,9 @@ module ArelExtensions
|
|
14
14
|
RETURN_TYPE = :number
|
15
15
|
attr_accessor :unbiased_estimator
|
16
16
|
|
17
|
-
def initialize node, opts
|
17
|
+
def initialize node, **opts
|
18
18
|
@unbiased_estimator = opts[:unbiased] ? true : false
|
19
|
-
super node, opts
|
19
|
+
super node, **opts
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -3,6 +3,15 @@ module ArelExtensions
|
|
3
3
|
class Arel::Visitors::ToSql
|
4
4
|
COMMA = ', ' unless defined?(COMMA)
|
5
5
|
|
6
|
+
# Escape properly the string expression expr.
|
7
|
+
# Take care of escaping.
|
8
|
+
def make_json_string expr
|
9
|
+
Arel::Nodes.build_quoted('"') \
|
10
|
+
+ expr
|
11
|
+
.replace('\\','\\\\').replace('"','\"').replace("\n", '\n') \
|
12
|
+
+ '"'
|
13
|
+
end
|
14
|
+
|
6
15
|
# Math Functions
|
7
16
|
def visit_ArelExtensions_Nodes_Abs o, collector
|
8
17
|
collector << "ABS("
|
@@ -589,7 +598,7 @@ module ArelExtensions
|
|
589
598
|
def json_value(o,v)
|
590
599
|
case o.type_of_node(v)
|
591
600
|
when :string
|
592
|
-
Arel.when(v.is_null).then(Arel::Nodes.build_quoted("null")).else(
|
601
|
+
Arel.when(v.is_null).then(Arel::Nodes.build_quoted("null")).else(make_json_string(v))
|
593
602
|
when :date
|
594
603
|
s = v.format('%Y-%m-%d')
|
595
604
|
Arel.when(s.is_null).then(Arel::Nodes.build_quoted("null")).else(Arel::Nodes.build_quoted('"') + s + '"')
|
@@ -624,7 +633,7 @@ module ArelExtensions
|
|
624
633
|
if i != 0
|
625
634
|
res += ', '
|
626
635
|
end
|
627
|
-
res +=
|
636
|
+
res += make_json_string(ArelExtensions::Nodes::Cast.new([k, :string]).coalesce("")) + ': '
|
628
637
|
res += json_value(o,v)
|
629
638
|
end
|
630
639
|
res += '}'
|
@@ -646,7 +655,7 @@ module ArelExtensions
|
|
646
655
|
if i != 0
|
647
656
|
res = res + ', '
|
648
657
|
end
|
649
|
-
kv =
|
658
|
+
kv = make_json_string(ArelExtensions::Nodes::Cast.new([k, :string]).coalesce("")) + ': '
|
650
659
|
kv += json_value(o,v)
|
651
660
|
res = res + kv.group_concat(', ', order: Array(orders)).coalesce('')
|
652
661
|
end
|
data/test/database.yml
CHANGED
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.2.
|
4
|
+
version: 1.2.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yann Azoury
|
@@ -10,10 +10,10 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-01-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: arel
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
@@ -81,6 +81,7 @@ extra_rdoc_files:
|
|
81
81
|
- functions.html
|
82
82
|
files:
|
83
83
|
- ".codeclimate.yml"
|
84
|
+
- ".github/workflows/ruby.yml"
|
84
85
|
- ".gitignore"
|
85
86
|
- ".rubocop.yml"
|
86
87
|
- ".travis.yml"
|
@@ -105,7 +106,9 @@ files:
|
|
105
106
|
- gemfiles/rails5_1_4.gemfile
|
106
107
|
- gemfiles/rails5_2.gemfile
|
107
108
|
- gemfiles/rails6.gemfile
|
108
|
-
-
|
109
|
+
- gemfiles/rails6_1.gemfile
|
110
|
+
- gemspecs/arel_extensions-v1.gemspec
|
111
|
+
- gemspecs/arel_extensions-v2.gemspec
|
109
112
|
- generate_gems.sh
|
110
113
|
- init/mssql.sql
|
111
114
|
- init/mysql.sql
|
@@ -219,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
219
222
|
- !ruby/object:Gem::Version
|
220
223
|
version: '0'
|
221
224
|
requirements: []
|
222
|
-
rubygems_version: 3.0.
|
225
|
+
rubygems_version: 3.0.6
|
223
226
|
signing_key:
|
224
227
|
specification_version: 4
|
225
228
|
summary: Extending Arel
|