arel_extensions 1.4.2 → 2.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +2 -1
- data/.gitignore +6 -7
- data/.rubocop.yml +3 -67
- data/.travis/oracle/download.js +152 -0
- data/.travis/oracle/download.sh +30 -0
- data/.travis/oracle/download_ojdbc.js +116 -0
- data/.travis/oracle/install.sh +34 -0
- data/.travis/setup_accounts.sh +9 -0
- data/.travis/sqlite3/extension-functions.sh +6 -0
- data/.travis.yml +223 -0
- data/Gemfile +28 -2
- data/README.md +90 -239
- data/Rakefile +30 -48
- data/TODO +1 -0
- data/appveyor.yml +22 -60
- data/arel_extensions.gemspec +14 -13
- data/functions.html +3 -3
- data/gemfiles/rails3.gemfile +10 -10
- data/gemfiles/rails4.gemfile +29 -0
- data/gemfiles/rails5_0.gemfile +29 -0
- data/gemfiles/rails5_1_4.gemfile +14 -14
- data/gemfiles/rails5_2.gemfile +14 -16
- data/init/mssql.sql +4 -4
- data/init/mysql.sql +38 -38
- data/init/oracle.sql +0 -0
- data/init/postgresql.sql +21 -21
- data/init/sqlite.sql +0 -0
- data/lib/arel_extensions/attributes.rb +3 -10
- data/lib/arel_extensions/boolean_functions.rb +14 -53
- data/lib/arel_extensions/common_sql_functions.rb +17 -16
- data/lib/arel_extensions/comparators.rb +28 -27
- data/lib/arel_extensions/date_duration.rb +13 -17
- data/lib/arel_extensions/insert_manager.rb +15 -18
- data/lib/arel_extensions/math.rb +53 -55
- data/lib/arel_extensions/math_functions.rb +39 -46
- data/lib/arel_extensions/nodes/abs.rb +1 -0
- data/lib/arel_extensions/nodes/blank.rb +2 -1
- data/lib/arel_extensions/nodes/case.rb +19 -20
- data/lib/arel_extensions/nodes/cast.rb +8 -10
- data/lib/arel_extensions/nodes/ceil.rb +1 -1
- data/lib/arel_extensions/nodes/coalesce.rb +4 -3
- data/lib/arel_extensions/nodes/collate.rb +10 -9
- data/lib/arel_extensions/nodes/concat.rb +18 -9
- data/lib/arel_extensions/nodes/date_diff.rb +26 -42
- data/lib/arel_extensions/nodes/duration.rb +3 -0
- data/lib/arel_extensions/nodes/find_in_set.rb +1 -0
- data/lib/arel_extensions/nodes/floor.rb +1 -1
- data/lib/arel_extensions/nodes/format.rb +8 -35
- data/lib/arel_extensions/nodes/formatted_number.rb +23 -22
- data/lib/arel_extensions/nodes/function.rb +37 -42
- data/lib/arel_extensions/nodes/is_null.rb +0 -0
- data/lib/arel_extensions/nodes/json.rb +39 -52
- data/lib/arel_extensions/nodes/length.rb +0 -5
- data/lib/arel_extensions/nodes/levenshtein_distance.rb +1 -1
- data/lib/arel_extensions/nodes/locate.rb +2 -1
- data/lib/arel_extensions/nodes/log10.rb +2 -1
- data/lib/arel_extensions/nodes/matches.rb +7 -5
- data/lib/arel_extensions/nodes/md5.rb +1 -0
- data/lib/arel_extensions/nodes/power.rb +5 -5
- data/lib/arel_extensions/nodes/rand.rb +1 -0
- data/lib/arel_extensions/nodes/repeat.rb +5 -3
- data/lib/arel_extensions/nodes/replace.rb +8 -16
- data/lib/arel_extensions/nodes/round.rb +6 -5
- data/lib/arel_extensions/nodes/soundex.rb +15 -15
- data/lib/arel_extensions/nodes/std.rb +21 -18
- data/lib/arel_extensions/nodes/substring.rb +16 -8
- data/lib/arel_extensions/nodes/then.rb +1 -1
- data/lib/arel_extensions/nodes/trim.rb +6 -4
- data/lib/arel_extensions/nodes/union.rb +8 -5
- data/lib/arel_extensions/nodes/union_all.rb +7 -4
- data/lib/arel_extensions/nodes/wday.rb +4 -0
- data/lib/arel_extensions/nodes.rb +1 -1
- data/lib/arel_extensions/null_functions.rb +5 -19
- data/lib/arel_extensions/predications.rb +43 -44
- data/lib/arel_extensions/railtie.rb +5 -5
- data/lib/arel_extensions/set_functions.rb +7 -5
- data/lib/arel_extensions/string_functions.rb +29 -59
- data/lib/arel_extensions/tasks.rb +6 -6
- data/lib/arel_extensions/version.rb +1 -1
- data/lib/arel_extensions/visitors/ibm_db.rb +31 -24
- data/lib/arel_extensions/visitors/mssql.rb +191 -422
- data/lib/arel_extensions/visitors/mysql.rb +212 -350
- data/lib/arel_extensions/visitors/oracle.rb +178 -220
- data/lib/arel_extensions/visitors/oracle12.rb +31 -18
- data/lib/arel_extensions/visitors/postgresql.rb +173 -256
- data/lib/arel_extensions/visitors/sqlite.rb +126 -140
- data/lib/arel_extensions/visitors/to_sql.rb +237 -298
- data/lib/arel_extensions/visitors.rb +62 -83
- data/lib/arel_extensions.rb +31 -224
- data/test/database.yml +7 -15
- data/test/helper.rb +18 -0
- data/test/real_db_test.rb +117 -120
- data/test/support/fake_record.rb +3 -9
- data/test/test_comparators.rb +17 -14
- data/test/visitors/test_bulk_insert_oracle.rb +11 -11
- data/test/visitors/test_bulk_insert_sqlite.rb +13 -12
- data/test/visitors/test_bulk_insert_to_sql.rb +13 -11
- data/test/visitors/test_oracle.rb +55 -55
- data/test/visitors/test_to_sql.rb +226 -419
- data/test/with_ar/all_agnostic_test.rb +366 -711
- data/test/with_ar/insert_agnostic_test.rb +21 -27
- data/test/with_ar/test_bulk_sqlite.rb +16 -17
- data/test/with_ar/test_math_sqlite.rb +26 -26
- data/test/with_ar/test_string_mysql.rb +33 -31
- data/test/with_ar/test_string_sqlite.rb +34 -30
- metadata +34 -43
- data/.github/workflows/publish.yml +0 -29
- data/.github/workflows/release.yml +0 -30
- data/.github/workflows/ruby.yml +0 -399
- data/CONTRIBUTING.md +0 -102
- data/NEWS.md +0 -89
- data/bin/build +0 -15
- data/bin/compose +0 -6
- data/bin/publish +0 -8
- data/dev/arelx.dockerfile +0 -44
- data/dev/compose.yaml +0 -71
- data/dev/postgres.dockerfile +0 -5
- data/dev/rbenv +0 -189
- data/gemfiles/rails4_2.gemfile +0 -38
- data/gemfiles/rails5.gemfile +0 -29
- data/gemfiles/rails6.gemfile +0 -33
- data/gemfiles/rails6_1.gemfile +0 -33
- data/gemfiles/rails7.gemfile +0 -33
- data/gemfiles/rails7_1.gemfile +0 -33
- data/gemfiles/rails7_2.gemfile +0 -33
- data/gemspecs/arel_extensions-v1.gemspec +0 -27
- data/gemspecs/arel_extensions-v2.gemspec +0 -27
- data/generate_gems.sh +0 -15
- data/lib/arel_extensions/aliases.rb +0 -14
- data/lib/arel_extensions/helpers.rb +0 -62
- data/lib/arel_extensions/nodes/aggregate_function.rb +0 -13
- data/lib/arel_extensions/nodes/formatted_date.rb +0 -42
- data/lib/arel_extensions/nodes/rollup.rb +0 -36
- data/lib/arel_extensions/nodes/select.rb +0 -10
- data/lib/arel_extensions/nodes/sum.rb +0 -7
- data/lib/arel_extensions/visitors/convert_format.rb +0 -37
- data/test/arelx_test_helper.rb +0 -74
- data/version_v1.rb +0 -3
- data/version_v2.rb +0 -3
data/appveyor.yml
CHANGED
@@ -1,82 +1,44 @@
|
|
1
|
-
image: Visual Studio 2015
|
2
|
-
|
3
1
|
version: "{build}"
|
4
2
|
|
5
3
|
cache:
|
6
4
|
- vendor/bundle
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
SQL: MSSQL$SQL2014
|
16
|
-
- RUBY_VERSION: 25-x64
|
17
|
-
RAILS: 4_2
|
18
|
-
SQL: MSSQL$SQL2016
|
19
|
-
- RUBY_VERSION: 25-x64
|
20
|
-
RAILS: 5_2
|
21
|
-
SQL: MSSQL$SQL2012SP1
|
22
|
-
- RUBY_VERSION: 25-x64
|
23
|
-
RAILS: 5_2
|
24
|
-
SQL: MSSQL$SQL2014
|
25
|
-
- RUBY_VERSION: 25-x64
|
26
|
-
RAILS: 5_2
|
27
|
-
SQL: MSSQL$SQL2016
|
28
|
-
- RUBY_VERSION: 25-x64
|
29
|
-
RAILS: 6
|
30
|
-
SQL: MSSQL$SQL2012SP1
|
31
|
-
- RUBY_VERSION: 25-x64
|
32
|
-
RAILS: 6
|
33
|
-
SQL: MSSQL$SQL2014
|
34
|
-
- RUBY_VERSION: 25-x64
|
35
|
-
RAILS: 6
|
36
|
-
SQL: MSSQL$SQL2016
|
37
|
-
- RUBY_VERSION: 25-x64
|
38
|
-
RAILS: 6_1
|
39
|
-
SQL: MSSQL$SQL2012SP1
|
40
|
-
- RUBY_VERSION: 25-x64
|
41
|
-
RAILS: 6_1
|
42
|
-
SQL: MSSQL$SQL2014
|
43
|
-
- RUBY_VERSION: 25-x64
|
44
|
-
RAILS: 6_1
|
45
|
-
SQL: MSSQL$SQL2016
|
6
|
+
branches:
|
7
|
+
only:
|
8
|
+
- master
|
9
|
+
|
10
|
+
services:
|
11
|
+
- mssql2014
|
12
|
+
|
46
13
|
|
47
14
|
install:
|
48
15
|
- set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
|
49
|
-
- gem update --system
|
50
|
-
- gem install rubygems-update && update_rubygems
|
51
16
|
- bundle config --local path vendor/bundle
|
52
|
-
- cp ./gemfiles/rails%RAILS%.gemfile ./Gemfile
|
53
|
-
- bundle config set gemfile ./gemfiles/rails%RAILS%.gemfile
|
54
17
|
- bundle install
|
55
18
|
|
19
|
+
# Disable normal Windows builds in favor of our test script.
|
56
20
|
build: off
|
57
21
|
|
22
|
+
|
58
23
|
before_test:
|
59
24
|
- ruby -v
|
60
25
|
- gem -v
|
61
26
|
- bundle -v
|
62
27
|
|
63
28
|
test_script:
|
64
|
-
-
|
65
|
-
-
|
29
|
+
- ruby --version
|
30
|
+
- gem --version
|
31
|
+
- bundler --version
|
32
|
+
- bundle exec rake test
|
33
|
+
- ps: Start-Service 'MSSQL$SQL2014'
|
34
|
+
- timeout /t 4 /nobreak > NUL
|
66
35
|
- bundle exec rake test:mssql
|
67
36
|
|
68
|
-
|
69
|
-
-
|
37
|
+
environment:
|
70
38
|
matrix:
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
-
|
75
|
-
-
|
76
|
-
|
77
|
-
- cp ./gemfiles/rails%RAILS%.gemfile ./Gemfile
|
78
|
-
- gem update --system
|
79
|
-
- gem install rubygems-update && update_rubygems
|
80
|
-
- bundle config --local path vendor/bundle
|
81
|
-
- bundle config set gemfile ./gemfiles/rails%RAILS%.gemfile
|
82
|
-
- bundle install
|
39
|
+
- RUBY_VERSION: 200
|
40
|
+
- RUBY_VERSION: 21
|
41
|
+
- RUBY_VERSION: 22
|
42
|
+
- RUBY_VERSION: 23
|
43
|
+
- RUBY_VERSION: 23-x64
|
44
|
+
|
data/arel_extensions.gemspec
CHANGED
@@ -1,27 +1,28 @@
|
|
1
|
-
$:.push File.expand_path(
|
2
|
-
require
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "arel_extensions/version"
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
|
-
s.name =
|
5
|
+
s.name = "arel_extensions"
|
6
6
|
s.version = ArelExtensions::VERSION
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
|
-
s.authors = [
|
9
|
-
s.email = [
|
10
|
-
s.homepage =
|
11
|
-
s.description =
|
12
|
-
s.summary =
|
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
13
|
s.license = 'MIT'
|
14
14
|
|
15
|
-
s.rdoc_options = [
|
16
|
-
s.extra_rdoc_files = [
|
15
|
+
s.rdoc_options = ["--main", "README.md"]
|
16
|
+
s.extra_rdoc_files = ["MIT-LICENSE.txt", "README.md", 'functions.html']
|
17
17
|
|
18
18
|
# Manifest
|
19
19
|
s.files = `git ls-files`.split("\n")
|
20
20
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
-
s.require_paths = [
|
21
|
+
s.require_paths = ["lib"]
|
22
22
|
|
23
|
-
s.add_dependency('
|
23
|
+
s.add_dependency('activerecord', '>= 6.0.0.rc2')
|
24
24
|
|
25
25
|
s.add_development_dependency('minitest', '~> 5.9')
|
26
|
-
s.add_development_dependency('
|
26
|
+
s.add_development_dependency('rdoc', '~> 4.0')
|
27
|
+
s.add_development_dependency('rake', '~> 11')
|
27
28
|
end
|
data/functions.html
CHANGED
@@ -55,7 +55,7 @@
|
|
55
55
|
<td class="tg-yw4l">CEIL<br>column.ceil</td>
|
56
56
|
<td class="ok">✔</td>
|
57
57
|
<td class="ok">✔</td>
|
58
|
-
<td class="tg-j6lv">CASE +
|
58
|
+
<td class="tg-j6lv">CASE + ROUND</td>
|
59
59
|
<td class="ok">✔</td>
|
60
60
|
<td class="tg-j6lv">CEILING()</td>
|
61
61
|
<td class="tg-j6lv">CEILING()</td>
|
@@ -64,7 +64,7 @@
|
|
64
64
|
<td class="tg-yw4l">FLOOR<br>column.floor</td>
|
65
65
|
<td class="ok">✔</td>
|
66
66
|
<td class="ok">✔</td>
|
67
|
-
<td class="tg-j6lv">CASE +
|
67
|
+
<td class="tg-j6lv">CASE + ROUND</td>
|
68
68
|
<td class="ok">✔</td>
|
69
69
|
<td class="ok">✔</td>
|
70
70
|
<td class="ok">✔</td>
|
@@ -379,7 +379,7 @@
|
|
379
379
|
<td class="ok">✔</td>
|
380
380
|
<td class="ok">✔</td>
|
381
381
|
<td class="ok">✔</td>
|
382
|
-
</tr>
|
382
|
+
</tr>
|
383
383
|
<tr>
|
384
384
|
<th class="bulk_insert" rowspan="1"><div>Set<br/> Operators</div></th>
|
385
385
|
<td class="tg-yw4l">UNION ( + )<br/>query + query</td>
|
data/gemfiles/rails3.gemfile
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
3
|
gem 'arel', '~> 3.0' # too old...
|
4
4
|
|
5
5
|
group :development, :test do
|
6
|
-
gem
|
7
|
-
gem
|
8
|
-
gem
|
9
|
-
gem
|
6
|
+
gem "sqlite3", '<= 1.3.13', :platform => [:ruby, :mswin, :mingw]
|
7
|
+
gem "mysql2", '0.4.10', :platform => [:ruby, :mswin, :mingw]
|
8
|
+
gem "activerecord-mysql2-adapter", :platform => [:ruby, :mswin, :mingw]
|
9
|
+
gem "pg", :platform => [:ruby, :mswin, :mingw]
|
10
10
|
# for JRuby
|
11
|
-
gem
|
12
|
-
gem
|
13
|
-
gem
|
14
|
-
gem
|
11
|
+
gem "jdbc-sqlite3", :platform => :jruby
|
12
|
+
gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
|
13
|
+
gem "activerecord-jdbcmysql-adapter", :platform => :jruby
|
14
|
+
gem "activerecord-jdbcpostgresql-adapter", :platform => :jruby
|
15
15
|
gem 'activesupport', '~> 3.2'
|
16
16
|
gem 'activemodel', '~> 3.2'
|
17
17
|
gem 'activerecord', '~> 3.2'
|
18
18
|
end
|
19
19
|
|
20
|
-
gemspec path
|
20
|
+
gemspec :path => "../"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gem 'arel', '~> 6.0'
|
4
|
+
|
5
|
+
group :development, :test do
|
6
|
+
gem 'activesupport', '~> 4.0'
|
7
|
+
gem 'activemodel', '~> 4.0'
|
8
|
+
gem 'activerecord', '~> 4.0'
|
9
|
+
|
10
|
+
gem "sqlite3", '<= 1.3.13', :platforms => [:mri, :mswin, :mingw]
|
11
|
+
gem "mysql2", '0.4.10', :platforms => [:mri, :mswin, :mingw]
|
12
|
+
gem "pg",'< 1.0.0', :platforms => [:mri, :mingw]
|
13
|
+
|
14
|
+
gem "tiny_tds", :platforms => [:mri, :mingw, :mswin] if RUBY_PLATFORM =~ /windows/
|
15
|
+
gem "activerecord-sqlserver-adapter", '~> 4.2.0', :platforms => [:mri, :mingw, :mswin] if RUBY_PLATFORM =~ /windows/
|
16
|
+
|
17
|
+
gem 'ruby-oci8', :platforms => [:mri, :mswin, :mingw] if ENV.has_key? 'ORACLE_HOME'
|
18
|
+
gem 'activerecord-oracle_enhanced-adapter', '~> 1.6.0' if ENV.has_key? 'ORACLE_HOME'
|
19
|
+
|
20
|
+
# for JRuby
|
21
|
+
gem 'activerecord-jdbc-adapter', :platforms => :jruby
|
22
|
+
gem "jdbc-sqlite3", :platforms => :jruby
|
23
|
+
gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
|
24
|
+
gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
|
25
|
+
gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby
|
26
|
+
gem "activerecord-jdbcmssql-adapter", :platforms => :jruby
|
27
|
+
end
|
28
|
+
|
29
|
+
gemspec :path => "../"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gem 'arel', '~> 7.0'
|
4
|
+
|
5
|
+
group :development, :test do
|
6
|
+
gem 'activesupport', '~> 5.0'
|
7
|
+
gem 'activemodel', '~> 5.0'
|
8
|
+
gem 'activerecord', '5.0.6'
|
9
|
+
|
10
|
+
gem "sqlite3", '<= 1.3.13', :platforms => [:mri, :mswin, :mingw]
|
11
|
+
gem "mysql2", '0.4.10', :platforms => [:mri, :mswin, :mingw]
|
12
|
+
gem "pg",'< 1.0.0', :platforms => [:mri, :mingw]
|
13
|
+
|
14
|
+
gem "tiny_tds", :platforms => [:mri, :mingw] if RUBY_PLATFORM =~ /windows/
|
15
|
+
#gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw]
|
16
|
+
|
17
|
+
gem 'ruby-oci8', :platforms => [:mri, :mswin, :mingw] if ENV.has_key? 'ORACLE_HOME'
|
18
|
+
gem 'activerecord-oracle_enhanced-adapter', '~> 1.7' if ENV.has_key? 'ORACLE_HOME'
|
19
|
+
|
20
|
+
# for JRuby
|
21
|
+
gem 'activerecord-jdbc-adapter', :github => 'jruby/activerecord-jdbc-adapter', :tag => 'v50.0', :platforms => :jruby
|
22
|
+
gem "jdbc-sqlite3", :platforms => :jruby
|
23
|
+
gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
|
24
|
+
gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
|
25
|
+
gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby
|
26
|
+
gem "activerecord-jdbcmssql-adapter", :platforms => :jruby
|
27
|
+
end
|
28
|
+
|
29
|
+
gemspec :path => "../"
|
data/gemfiles/rails5_1_4.gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
3
|
gem 'rails', '5.1.4'
|
4
4
|
gem 'arel', '~> 8'
|
@@ -8,23 +8,23 @@ group :development, :test do
|
|
8
8
|
gem 'activemodel', '5.1.4'
|
9
9
|
gem 'activerecord', '5.1.4'
|
10
10
|
|
11
|
-
gem
|
12
|
-
gem
|
13
|
-
gem
|
11
|
+
gem "sqlite3", '<= 1.3.13', :platforms => [:mri, :mswin, :mingw]
|
12
|
+
gem "mysql2", '0.4.10', :platforms => [:mri, :mswin, :mingw]
|
13
|
+
gem "pg",'< 1.0.0', :platforms => [:mri, :mingw]
|
14
14
|
|
15
|
-
gem
|
16
|
-
#
|
15
|
+
gem "tiny_tds", :platforms => [:mri, :mingw] if RUBY_PLATFORM =~ /windows/
|
16
|
+
#gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw]
|
17
17
|
|
18
|
-
gem 'ruby-oci8', platforms
|
18
|
+
gem 'ruby-oci8', :platforms => [:mri, :mswin, :mingw] if ENV.has_key? 'ORACLE_HOME'
|
19
19
|
gem 'activerecord-oracle_enhanced-adapter', '~> 1.8' if ENV.has_key? 'ORACLE_HOME'
|
20
20
|
|
21
21
|
# for JRuby
|
22
|
-
gem 'activerecord-jdbc-adapter', github
|
23
|
-
gem
|
24
|
-
gem
|
25
|
-
gem
|
26
|
-
gem
|
27
|
-
gem
|
22
|
+
gem 'activerecord-jdbc-adapter', :github => 'jruby/activerecord-jdbc-adapter', :tag => 'v51.0', :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
28
|
end
|
29
29
|
|
30
|
-
gemspec path
|
30
|
+
gemspec :path => "../"
|
data/gemfiles/rails5_2.gemfile
CHANGED
@@ -1,32 +1,30 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
3
|
gem 'rails', '~> 5.2.0'
|
4
4
|
gem 'arel', '~> 9'
|
5
5
|
|
6
6
|
group :development, :test do
|
7
|
-
gem 'bigdecimal', '1.3.5', platforms: %i[mri mingw x64_mingw mswin]
|
8
7
|
gem 'activesupport', '~> 5.2.0'
|
9
8
|
gem 'activemodel', '~> 5.2.0'
|
10
9
|
gem 'activerecord', '~> 5.2.0'
|
11
10
|
|
12
|
-
gem
|
13
|
-
gem
|
14
|
-
gem
|
11
|
+
gem "sqlite3", '<= 1.3.13', :platforms => [:mri, :mswin, :mingw]
|
12
|
+
gem "mysql2", '0.4.10', :platforms => [:mri, :mswin, :mingw]
|
13
|
+
gem "pg",'< 1.0.0', :platforms => [:mri, :mingw]
|
15
14
|
|
16
|
-
gem
|
17
|
-
gem
|
18
|
-
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw]
|
15
|
+
gem "tiny_tds", :platforms => [:mri, :mingw] if RUBY_PLATFORM =~ /windows/
|
16
|
+
#gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw]
|
19
17
|
|
20
|
-
gem 'ruby-oci8', platforms
|
18
|
+
gem 'ruby-oci8', :platforms => [:mri, :mswin, :mingw] if ENV.has_key? 'ORACLE_HOME'
|
21
19
|
gem 'activerecord-oracle_enhanced-adapter', '~> 5.2.0' if ENV.has_key? 'ORACLE_HOME'
|
22
20
|
|
23
21
|
# for JRuby
|
24
|
-
gem 'activerecord-jdbc-adapter', github
|
25
|
-
gem
|
26
|
-
gem
|
27
|
-
gem
|
28
|
-
gem
|
29
|
-
gem
|
22
|
+
gem 'activerecord-jdbc-adapter', :github => 'jruby/activerecord-jdbc-adapter', :tag => 'v52.0', :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
|
30
28
|
end
|
31
29
|
|
32
|
-
gemspec path
|
30
|
+
gemspec :path => "../"
|
data/init/mssql.sql
CHANGED
@@ -83,7 +83,7 @@ BEGIN
|
|
83
83
|
END
|
84
84
|
SELECT @cv1 = @cv0, @i = @i + 1
|
85
85
|
END
|
86
|
-
RETURN @c
|
86
|
+
RETURN @c
|
87
87
|
END
|
88
88
|
GO
|
89
89
|
|
@@ -94,9 +94,9 @@ GO
|
|
94
94
|
--RETURNS TABLE
|
95
95
|
--AS
|
96
96
|
--BEGIN
|
97
|
-
-- RETURN ( SELECT [Value] FROM
|
98
|
-
-- (
|
99
|
-
-- SELECT
|
97
|
+
-- RETURN ( SELECT [Value] FROM
|
98
|
+
-- (
|
99
|
+
-- SELECT
|
100
100
|
-- [Value] = LTRIM(RTRIM(SUBSTRING(@List, [Number],
|
101
101
|
-- CHARINDEX(@Delim, @List + @Delim, [Number]) - [Number])))
|
102
102
|
-- FROM (SELECT Number = ROW_NUMBER() OVER (ORDER BY name)
|
data/init/mysql.sql
CHANGED
@@ -1,45 +1,45 @@
|
|
1
1
|
DELIMITER $$
|
2
2
|
|
3
3
|
DROP FUNCTION IF EXISTS levenshtein_distance; $$
|
4
|
-
CREATE FUNCTION levenshtein_distance( s1 VARCHAR(255), s2 VARCHAR(255) )
|
5
|
-
RETURNS INT
|
6
|
-
DETERMINISTIC
|
7
|
-
BEGIN
|
8
|
-
DECLARE s1_len, s2_len, i, j, c, c_temp, cost INT;
|
9
|
-
DECLARE s1_char CHAR;
|
10
|
-
-- max strlen=255
|
11
|
-
DECLARE cv0, cv1 VARBINARY(256);
|
4
|
+
CREATE FUNCTION levenshtein_distance( s1 VARCHAR(255), s2 VARCHAR(255) )
|
5
|
+
RETURNS INT
|
6
|
+
DETERMINISTIC
|
7
|
+
BEGIN
|
8
|
+
DECLARE s1_len, s2_len, i, j, c, c_temp, cost INT;
|
9
|
+
DECLARE s1_char CHAR;
|
10
|
+
-- max strlen=255
|
11
|
+
DECLARE cv0, cv1 VARBINARY(256);
|
12
12
|
SET s1 = IFNULL(s1,''), s2 = IFNULL(s2,'');
|
13
|
-
SET s1_len = CHAR_LENGTH(IFNULL(s1,'')), s2_len = CHAR_LENGTH(IFNULL(s2,'')), cv1 = 0x00, j = 1, i = 1, c = 0;
|
14
|
-
IF s1_len = 0 THEN
|
15
|
-
RETURN s2_len;
|
16
|
-
ELSEIF s2_len = 0 THEN
|
17
|
-
RETURN s1_len;
|
18
|
-
ELSEIF s1 = s2 THEN
|
13
|
+
SET s1_len = CHAR_LENGTH(IFNULL(s1,'')), s2_len = CHAR_LENGTH(IFNULL(s2,'')), cv1 = 0x00, j = 1, i = 1, c = 0;
|
14
|
+
IF s1_len = 0 THEN
|
15
|
+
RETURN s2_len;
|
16
|
+
ELSEIF s2_len = 0 THEN
|
17
|
+
RETURN s1_len;
|
18
|
+
ELSEIF s1 = s2 THEN
|
19
19
|
RETURN 0;
|
20
|
-
ELSE
|
21
|
-
WHILE j <= s2_len DO
|
22
|
-
SET cv1 = CONCAT(cv1, UNHEX(HEX(j))), j = j + 1;
|
23
|
-
END WHILE;
|
24
|
-
WHILE i <= s1_len DO
|
25
|
-
SET s1_char = SUBSTRING(s1, i, 1), c = i, cv0 = UNHEX(HEX(i)), j = 1;
|
26
|
-
WHILE j <= s2_len DO
|
27
|
-
SET c = c + 1;
|
28
|
-
IF s1_char = SUBSTRING(s2, j, 1) THEN
|
29
|
-
SET cost = 0; ELSE SET cost = 1;
|
30
|
-
END IF;
|
31
|
-
SET c_temp = CONV(HEX(SUBSTRING(cv1, j, 1)), 16, 10) + cost;
|
32
|
-
IF c > c_temp THEN SET c = c_temp; END IF;
|
33
|
-
SET c_temp = CONV(HEX(SUBSTRING(cv1, j+1, 1)), 16, 10) + 1;
|
34
|
-
IF c > c_temp THEN
|
35
|
-
SET c = c_temp;
|
36
|
-
END IF;
|
37
|
-
SET cv0 = CONCAT(cv0, UNHEX(HEX(c))), j = j + 1;
|
38
|
-
END WHILE;
|
39
|
-
SET cv1 = cv0, i = i + 1;
|
40
|
-
END WHILE;
|
41
|
-
END IF;
|
42
|
-
RETURN c;
|
20
|
+
ELSE
|
21
|
+
WHILE j <= s2_len DO
|
22
|
+
SET cv1 = CONCAT(cv1, UNHEX(HEX(j))), j = j + 1;
|
23
|
+
END WHILE;
|
24
|
+
WHILE i <= s1_len DO
|
25
|
+
SET s1_char = SUBSTRING(s1, i, 1), c = i, cv0 = UNHEX(HEX(i)), j = 1;
|
26
|
+
WHILE j <= s2_len DO
|
27
|
+
SET c = c + 1;
|
28
|
+
IF s1_char = SUBSTRING(s2, j, 1) THEN
|
29
|
+
SET cost = 0; ELSE SET cost = 1;
|
30
|
+
END IF;
|
31
|
+
SET c_temp = CONV(HEX(SUBSTRING(cv1, j, 1)), 16, 10) + cost;
|
32
|
+
IF c > c_temp THEN SET c = c_temp; END IF;
|
33
|
+
SET c_temp = CONV(HEX(SUBSTRING(cv1, j+1, 1)), 16, 10) + 1;
|
34
|
+
IF c > c_temp THEN
|
35
|
+
SET c = c_temp;
|
36
|
+
END IF;
|
37
|
+
SET cv0 = CONCAT(cv0, UNHEX(HEX(c))), j = j + 1;
|
38
|
+
END WHILE;
|
39
|
+
SET cv1 = cv0, i = i + 1;
|
40
|
+
END WHILE;
|
41
|
+
END IF;
|
42
|
+
RETURN c;
|
43
43
|
END;$$
|
44
|
-
|
44
|
+
|
45
45
|
DELIMITER ;
|
data/init/oracle.sql
CHANGED
File without changes
|
data/init/postgresql.sql
CHANGED
@@ -4,17 +4,17 @@ CREATE OR REPLACE FUNCTION public.find_in_set(n INTEGER, s TEXT)
|
|
4
4
|
AS $function$
|
5
5
|
SELECT * FROM (
|
6
6
|
select int4(z.row_number) from (
|
7
|
-
select row_number() over(), y.x
|
7
|
+
select row_number() over(), y.x
|
8
8
|
from (select unnest(('{' || $2 || '}')::int[]) as x) as y
|
9
9
|
) as z
|
10
10
|
where z.x = $1
|
11
|
-
UNION ALL
|
11
|
+
UNION ALL
|
12
12
|
SELECT 0) z
|
13
13
|
LIMIT 1
|
14
14
|
$function$
|
15
15
|
;
|
16
16
|
|
17
|
-
CREATE OR REPLACE FUNCTION public.levenshtein_distance(s text, t text)
|
17
|
+
CREATE OR REPLACE FUNCTION public.levenshtein_distance(s text, t text)
|
18
18
|
RETURNS integer AS $$
|
19
19
|
DECLARE i integer;
|
20
20
|
DECLARE j integer;
|
@@ -48,58 +48,58 @@ BEGIN
|
|
48
48
|
d[i*(n+1)+j] := LEAST(d[(i-1)*(n+1)+j]+1, d[i*(n+1)+j-1]+1, d[(i-1)*(n+1)+j-1]+c);
|
49
49
|
END LOOP;
|
50
50
|
END LOOP;
|
51
|
-
|
52
|
-
return d[m*(n+1)+n];
|
51
|
+
|
52
|
+
return d[m*(n+1)+n];
|
53
53
|
END;
|
54
54
|
$$ LANGUAGE plpgsql IMMUTABLE;
|
55
55
|
|
56
|
-
CREATE OR REPLACE FUNCTION public.DateDiff(units VARCHAR(30), start_t TIMESTAMP, end_t TIMESTAMP)
|
56
|
+
CREATE OR REPLACE FUNCTION public.DateDiff(units VARCHAR(30), start_t TIMESTAMP, end_t TIMESTAMP)
|
57
57
|
RETURNS INT AS $$
|
58
58
|
DECLARE
|
59
|
-
diff_interval INTERVAL;
|
59
|
+
diff_interval INTERVAL;
|
60
60
|
diff INT = 0;
|
61
61
|
years_diff INT = 0;
|
62
62
|
BEGIN
|
63
63
|
IF units IN ('yy', 'yyyy', 'year', 'mm', 'm', 'month') THEN
|
64
64
|
years_diff = DATE_PART('year', end_t) - DATE_PART('year', start_t);
|
65
|
-
|
65
|
+
|
66
66
|
IF units IN ('yy', 'yyyy', 'year') THEN
|
67
67
|
-- SQL Server does not count full years passed (only difference between year parts)
|
68
68
|
RETURN years_diff;
|
69
69
|
ELSE
|
70
70
|
-- If end month is less than start month it will subtracted
|
71
|
-
RETURN years_diff * 12 + (DATE_PART('month', end_t) - DATE_PART('month', start_t));
|
71
|
+
RETURN years_diff * 12 + (DATE_PART('month', end_t) - DATE_PART('month', start_t));
|
72
72
|
END IF;
|
73
73
|
END IF;
|
74
|
-
|
75
|
-
-- Minus operator returns interval 'DDD days HH:MI:SS'
|
74
|
+
|
75
|
+
-- Minus operator returns interval 'DDD days HH:MI:SS'
|
76
76
|
diff_interval = end_t - start_t;
|
77
|
-
|
77
|
+
|
78
78
|
diff = diff + DATE_PART('day', diff_interval);
|
79
|
-
|
79
|
+
|
80
80
|
IF units IN ('wk', 'ww', 'week') THEN
|
81
81
|
diff = diff/7;
|
82
82
|
RETURN diff;
|
83
83
|
END IF;
|
84
|
-
|
84
|
+
|
85
85
|
IF units IN ('dd', 'd', 'day') THEN
|
86
86
|
RETURN diff;
|
87
87
|
END IF;
|
88
|
-
|
89
|
-
diff = diff * 24 + DATE_PART('hour', diff_interval);
|
90
|
-
|
88
|
+
|
89
|
+
diff = diff * 24 + DATE_PART('hour', diff_interval);
|
90
|
+
|
91
91
|
IF units IN ('hh', 'hour') THEN
|
92
92
|
RETURN diff;
|
93
93
|
END IF;
|
94
|
-
|
94
|
+
|
95
95
|
diff = diff * 60 + DATE_PART('minute', diff_interval);
|
96
|
-
|
96
|
+
|
97
97
|
IF units IN ('mi', 'n', 'minute') THEN
|
98
98
|
RETURN diff;
|
99
99
|
END IF;
|
100
|
-
|
100
|
+
|
101
101
|
diff = diff * 60 + DATE_PART('second', diff_interval);
|
102
|
-
|
102
|
+
|
103
103
|
RETURN diff;
|
104
104
|
END;
|
105
105
|
$$ LANGUAGE plpgsql;
|
data/init/sqlite.sql
CHANGED
File without changes
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'arel_extensions/aliases'
|
2
1
|
require 'arel_extensions/math'
|
3
2
|
require 'arel_extensions/comparators'
|
4
3
|
require 'arel_extensions/date_duration'
|
@@ -9,7 +8,6 @@ require 'arel_extensions/predications'
|
|
9
8
|
|
10
9
|
module ArelExtensions
|
11
10
|
module Attributes
|
12
|
-
include ArelExtensions::Aliases
|
13
11
|
include ArelExtensions::Math
|
14
12
|
include ArelExtensions::Comparators
|
15
13
|
include ArelExtensions::DateDuration
|
@@ -19,17 +17,12 @@ module ArelExtensions
|
|
19
17
|
include ArelExtensions::Predications
|
20
18
|
|
21
19
|
def ==(other)
|
22
|
-
|
23
|
-
warn("#{caller(1..1).first} arel_extensions: `==` is now deprecated and will be removed soon. Use `.eq` instead.")
|
24
|
-
end
|
25
|
-
Arel::Nodes::Equality.new self, Arel.quoted(other, self)
|
20
|
+
Arel::Nodes::Equality.new self, Arel::Nodes.build_quoted(other, self)
|
26
21
|
end
|
27
22
|
|
28
23
|
def !=(other)
|
29
|
-
|
30
|
-
warn("#{caller(1..1).first} arel_extensions: `!=` is now deprecated and will be removed soon. Use `.not_eq` instead.")
|
31
|
-
end
|
32
|
-
Arel::Nodes::NotEqual.new self, Arel.quoted(other, self)
|
24
|
+
Arel::Nodes::NotEqual.new self, Arel::Nodes.build_quoted(other, self)
|
33
25
|
end
|
26
|
+
|
34
27
|
end
|
35
28
|
end
|