arel_extensions 1.2.23 → 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/.rubocop.yml +4 -7
- data/.travis.yml +91 -61
- data/Gemfile +20 -15
- data/README.md +12 -17
- data/Rakefile +29 -40
- data/appveyor.yml +1 -1
- data/arel_extensions.gemspec +3 -3
- data/functions.html +3 -3
- data/gemfiles/rails3.gemfile +9 -9
- data/gemfiles/rails4.gemfile +13 -13
- data/gemfiles/rails5_0.gemfile +13 -13
- data/gemfiles/rails5_1_4.gemfile +13 -13
- data/gemfiles/rails5_2.gemfile +13 -13
- data/init/mssql.sql +4 -4
- data/init/mysql.sql +38 -38
- data/init/postgresql.sql +21 -21
- data/lib/arel_extensions.rb +19 -69
- data/lib/arel_extensions/attributes.rb +1 -0
- data/lib/arel_extensions/boolean_functions.rb +14 -55
- data/lib/arel_extensions/common_sql_functions.rb +8 -7
- data/lib/arel_extensions/comparators.rb +15 -14
- data/lib/arel_extensions/date_duration.rb +5 -4
- data/lib/arel_extensions/insert_manager.rb +16 -17
- data/lib/arel_extensions/math.rb +12 -11
- data/lib/arel_extensions/math_functions.rb +22 -29
- data/lib/arel_extensions/nodes.rb +1 -1
- data/lib/arel_extensions/nodes/abs.rb +1 -0
- data/lib/arel_extensions/nodes/blank.rb +1 -0
- data/lib/arel_extensions/nodes/case.rb +8 -11
- data/lib/arel_extensions/nodes/cast.rb +2 -4
- data/lib/arel_extensions/nodes/ceil.rb +1 -1
- data/lib/arel_extensions/nodes/change_case.rb +0 -0
- data/lib/arel_extensions/nodes/coalesce.rb +3 -2
- data/lib/arel_extensions/nodes/collate.rb +2 -1
- data/lib/arel_extensions/nodes/concat.rb +16 -7
- data/lib/arel_extensions/nodes/date_diff.rb +13 -10
- 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 -34
- data/lib/arel_extensions/nodes/formatted_number.rb +23 -22
- data/lib/arel_extensions/nodes/function.rb +16 -25
- data/lib/arel_extensions/nodes/json.rb +36 -43
- data/lib/arel_extensions/nodes/length.rb +1 -0
- data/lib/arel_extensions/nodes/levenshtein_distance.rb +0 -0
- data/lib/arel_extensions/nodes/locate.rb +1 -0
- data/lib/arel_extensions/nodes/log10.rb +2 -1
- data/lib/arel_extensions/nodes/matches.rb +6 -4
- 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 +4 -2
- data/lib/arel_extensions/nodes/replace.rb +6 -22
- 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 +0 -0
- data/lib/arel_extensions/nodes/trim.rb +5 -3
- data/lib/arel_extensions/nodes/union.rb +5 -2
- data/lib/arel_extensions/nodes/union_all.rb +3 -0
- data/lib/arel_extensions/nodes/wday.rb +4 -0
- data/lib/arel_extensions/null_functions.rb +7 -5
- data/lib/arel_extensions/predications.rb +34 -35
- data/lib/arel_extensions/railtie.rb +5 -5
- data/lib/arel_extensions/set_functions.rb +4 -2
- data/lib/arel_extensions/string_functions.rb +22 -43
- data/lib/arel_extensions/tasks.rb +5 -5
- data/lib/arel_extensions/version.rb +1 -1
- data/lib/arel_extensions/visitors.rb +60 -68
- data/lib/arel_extensions/visitors/ibm_db.rb +12 -5
- data/lib/arel_extensions/visitors/mssql.rb +57 -63
- data/lib/arel_extensions/visitors/mysql.rb +98 -149
- data/lib/arel_extensions/visitors/oracle.rb +68 -71
- data/lib/arel_extensions/visitors/oracle12.rb +15 -2
- data/lib/arel_extensions/visitors/postgresql.rb +63 -116
- data/lib/arel_extensions/visitors/sqlite.rb +70 -83
- data/lib/arel_extensions/visitors/to_sql.rb +109 -141
- data/test/database.yml +0 -2
- data/test/helper.rb +18 -0
- data/test/real_db_test.rb +43 -28
- data/test/support/fake_record.rb +2 -2
- data/test/test_comparators.rb +12 -9
- data/test/visitors/test_bulk_insert_oracle.rb +8 -8
- data/test/visitors/test_bulk_insert_sqlite.rb +10 -9
- data/test/visitors/test_bulk_insert_to_sql.rb +10 -8
- data/test/visitors/test_oracle.rb +42 -42
- data/test/visitors/test_to_sql.rb +196 -361
- data/test/with_ar/all_agnostic_test.rb +160 -195
- data/test/with_ar/insert_agnostic_test.rb +4 -3
- data/test/with_ar/test_bulk_sqlite.rb +9 -6
- data/test/with_ar/test_math_sqlite.rb +12 -8
- data/test/with_ar/test_string_mysql.rb +11 -5
- data/test/with_ar/test_string_sqlite.rb +12 -4
- metadata +11 -22
- data/.github/workflows/ruby.yml +0 -102
- data/gemfiles/rails6.gemfile +0 -30
- data/gemfiles/rails6_1.gemfile +0 -30
- data/gemspecs/arel_extensions-v1.gemspec +0 -28
- data/gemspecs/arel_extensions-v2.gemspec +0 -28
- data/generate_gems.sh +0 -15
- data/lib/arel_extensions/nodes/aggregate_function.rb +0 -13
- 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 -26
- data/version_v1.rb +0 -3
- data/version_v2.rb +0 -3
data/gemfiles/rails6_1.gemfile
DELETED
@@ -1,30 +0,0 @@
|
|
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: "../"
|
@@ -1,28 +0,0 @@
|
|
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
|
@@ -1,28 +0,0 @@
|
|
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('activerecord', '>= 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
|
data/generate_gems.sh
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
|
2
|
-
#gem uninstall arel_extensions
|
3
|
-
|
4
|
-
# VERSION ~> 1
|
5
|
-
cp ./version_v1.rb lib/arel_extensions/version.rb
|
6
|
-
cp ./gemspecs/arel_extensions-v1.gemspec ./arel_extensions.gemspec
|
7
|
-
gem build ./arel_extensions.gemspec
|
8
|
-
|
9
|
-
# VERSION ~> 2
|
10
|
-
cp ./version_v2.rb lib/arel_extensions/version.rb
|
11
|
-
mv ./arel_extensions.gemspec ./arel_extensions.gemspec.bck
|
12
|
-
cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
|
13
|
-
gem build ./arel_extensions.gemspec
|
14
|
-
cp ./version_v1.rb lib/arel_extensions/version.rb
|
15
|
-
cp ./gemspecs/arel_extensions-v1.gemspec ./arel_extensions.gemspec
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module ArelExtensions
|
2
|
-
module Nodes
|
3
|
-
class AggregateFunction < Function
|
4
|
-
attr_accessor :order, :group
|
5
|
-
|
6
|
-
def initialize node, **opts
|
7
|
-
@order = Array(opts[:order]).map{|e| convert_to_node(e)}
|
8
|
-
@group = Array(opts[:group]).map{|e| convert_to_node(e)}
|
9
|
-
super [node]
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module ArelExtensions
|
2
|
-
module Visitors
|
3
|
-
# Convert date format in strftime syntax to whatever the RDBMs
|
4
|
-
# wants, based on the table of conversion +mapping+.
|
5
|
-
def self.strftime_to_format format, mapping
|
6
|
-
@mapping_regexps ||= {}
|
7
|
-
@mapping_regexps[mapping] ||=
|
8
|
-
Regexp.new(
|
9
|
-
mapping
|
10
|
-
.keys
|
11
|
-
.map{|k| Regexp.escape(k)}
|
12
|
-
.join('|')
|
13
|
-
)
|
14
|
-
|
15
|
-
regexp = @mapping_regexps[mapping]
|
16
|
-
s = StringScanner.new format
|
17
|
-
res = StringIO.new
|
18
|
-
while !s.eos?
|
19
|
-
res <<
|
20
|
-
case
|
21
|
-
when s.scan(regexp)
|
22
|
-
if v = mapping[s.matched]
|
23
|
-
v
|
24
|
-
else
|
25
|
-
# Should never happen.
|
26
|
-
s.matched
|
27
|
-
end
|
28
|
-
when s.scan(/[^%]+/)
|
29
|
-
s.matched
|
30
|
-
when s.scan(/./)
|
31
|
-
s.matched
|
32
|
-
end
|
33
|
-
end
|
34
|
-
res.string
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
data/test/arelx_test_helper.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'minitest/autorun'
|
3
|
-
require 'fileutils'
|
4
|
-
require 'arel'
|
5
|
-
require 'active_record'
|
6
|
-
|
7
|
-
require 'support/fake_record'
|
8
|
-
|
9
|
-
require 'arel_extensions'
|
10
|
-
Arel::Table.engine = FakeRecord::Base.new
|
11
|
-
|
12
|
-
$arel_silence_type_casting_deprecation = true
|
13
|
-
|
14
|
-
module Minitest::Assertions
|
15
|
-
#
|
16
|
-
# Fails unless +expected and +actual are the same string, modulo extraneous spaces.
|
17
|
-
#
|
18
|
-
def assert_like(expected, actual, msg = nil)
|
19
|
-
msg ||= "Expected #{expected.inspect} and #{actual.inspect} to be alike"
|
20
|
-
assert_equal expected.gsub(/\s+/, ' ').strip, actual.gsub(/\s+/, ' ').strip
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
module Minitest::Expectations
|
25
|
-
infect_an_assertion :assert_like, :must_be_like
|
26
|
-
end
|
data/version_v1.rb
DELETED
data/version_v2.rb
DELETED