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.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -7
  3. data/.travis.yml +91 -61
  4. data/Gemfile +20 -15
  5. data/README.md +12 -17
  6. data/Rakefile +29 -40
  7. data/appveyor.yml +1 -1
  8. data/arel_extensions.gemspec +3 -3
  9. data/functions.html +3 -3
  10. data/gemfiles/rails3.gemfile +9 -9
  11. data/gemfiles/rails4.gemfile +13 -13
  12. data/gemfiles/rails5_0.gemfile +13 -13
  13. data/gemfiles/rails5_1_4.gemfile +13 -13
  14. data/gemfiles/rails5_2.gemfile +13 -13
  15. data/init/mssql.sql +4 -4
  16. data/init/mysql.sql +38 -38
  17. data/init/postgresql.sql +21 -21
  18. data/lib/arel_extensions.rb +19 -69
  19. data/lib/arel_extensions/attributes.rb +1 -0
  20. data/lib/arel_extensions/boolean_functions.rb +14 -55
  21. data/lib/arel_extensions/common_sql_functions.rb +8 -7
  22. data/lib/arel_extensions/comparators.rb +15 -14
  23. data/lib/arel_extensions/date_duration.rb +5 -4
  24. data/lib/arel_extensions/insert_manager.rb +16 -17
  25. data/lib/arel_extensions/math.rb +12 -11
  26. data/lib/arel_extensions/math_functions.rb +22 -29
  27. data/lib/arel_extensions/nodes.rb +1 -1
  28. data/lib/arel_extensions/nodes/abs.rb +1 -0
  29. data/lib/arel_extensions/nodes/blank.rb +1 -0
  30. data/lib/arel_extensions/nodes/case.rb +8 -11
  31. data/lib/arel_extensions/nodes/cast.rb +2 -4
  32. data/lib/arel_extensions/nodes/ceil.rb +1 -1
  33. data/lib/arel_extensions/nodes/change_case.rb +0 -0
  34. data/lib/arel_extensions/nodes/coalesce.rb +3 -2
  35. data/lib/arel_extensions/nodes/collate.rb +2 -1
  36. data/lib/arel_extensions/nodes/concat.rb +16 -7
  37. data/lib/arel_extensions/nodes/date_diff.rb +13 -10
  38. data/lib/arel_extensions/nodes/duration.rb +3 -0
  39. data/lib/arel_extensions/nodes/find_in_set.rb +1 -0
  40. data/lib/arel_extensions/nodes/floor.rb +1 -1
  41. data/lib/arel_extensions/nodes/format.rb +8 -34
  42. data/lib/arel_extensions/nodes/formatted_number.rb +23 -22
  43. data/lib/arel_extensions/nodes/function.rb +16 -25
  44. data/lib/arel_extensions/nodes/json.rb +36 -43
  45. data/lib/arel_extensions/nodes/length.rb +1 -0
  46. data/lib/arel_extensions/nodes/levenshtein_distance.rb +0 -0
  47. data/lib/arel_extensions/nodes/locate.rb +1 -0
  48. data/lib/arel_extensions/nodes/log10.rb +2 -1
  49. data/lib/arel_extensions/nodes/matches.rb +6 -4
  50. data/lib/arel_extensions/nodes/md5.rb +1 -0
  51. data/lib/arel_extensions/nodes/power.rb +5 -5
  52. data/lib/arel_extensions/nodes/rand.rb +1 -0
  53. data/lib/arel_extensions/nodes/repeat.rb +4 -2
  54. data/lib/arel_extensions/nodes/replace.rb +6 -22
  55. data/lib/arel_extensions/nodes/round.rb +6 -5
  56. data/lib/arel_extensions/nodes/soundex.rb +15 -15
  57. data/lib/arel_extensions/nodes/std.rb +21 -18
  58. data/lib/arel_extensions/nodes/substring.rb +16 -8
  59. data/lib/arel_extensions/nodes/then.rb +0 -0
  60. data/lib/arel_extensions/nodes/trim.rb +5 -3
  61. data/lib/arel_extensions/nodes/union.rb +5 -2
  62. data/lib/arel_extensions/nodes/union_all.rb +3 -0
  63. data/lib/arel_extensions/nodes/wday.rb +4 -0
  64. data/lib/arel_extensions/null_functions.rb +7 -5
  65. data/lib/arel_extensions/predications.rb +34 -35
  66. data/lib/arel_extensions/railtie.rb +5 -5
  67. data/lib/arel_extensions/set_functions.rb +4 -2
  68. data/lib/arel_extensions/string_functions.rb +22 -43
  69. data/lib/arel_extensions/tasks.rb +5 -5
  70. data/lib/arel_extensions/version.rb +1 -1
  71. data/lib/arel_extensions/visitors.rb +60 -68
  72. data/lib/arel_extensions/visitors/ibm_db.rb +12 -5
  73. data/lib/arel_extensions/visitors/mssql.rb +57 -63
  74. data/lib/arel_extensions/visitors/mysql.rb +98 -149
  75. data/lib/arel_extensions/visitors/oracle.rb +68 -71
  76. data/lib/arel_extensions/visitors/oracle12.rb +15 -2
  77. data/lib/arel_extensions/visitors/postgresql.rb +63 -116
  78. data/lib/arel_extensions/visitors/sqlite.rb +70 -83
  79. data/lib/arel_extensions/visitors/to_sql.rb +109 -141
  80. data/test/database.yml +0 -2
  81. data/test/helper.rb +18 -0
  82. data/test/real_db_test.rb +43 -28
  83. data/test/support/fake_record.rb +2 -2
  84. data/test/test_comparators.rb +12 -9
  85. data/test/visitors/test_bulk_insert_oracle.rb +8 -8
  86. data/test/visitors/test_bulk_insert_sqlite.rb +10 -9
  87. data/test/visitors/test_bulk_insert_to_sql.rb +10 -8
  88. data/test/visitors/test_oracle.rb +42 -42
  89. data/test/visitors/test_to_sql.rb +196 -361
  90. data/test/with_ar/all_agnostic_test.rb +160 -195
  91. data/test/with_ar/insert_agnostic_test.rb +4 -3
  92. data/test/with_ar/test_bulk_sqlite.rb +9 -6
  93. data/test/with_ar/test_math_sqlite.rb +12 -8
  94. data/test/with_ar/test_string_mysql.rb +11 -5
  95. data/test/with_ar/test_string_sqlite.rb +12 -4
  96. metadata +11 -22
  97. data/.github/workflows/ruby.yml +0 -102
  98. data/gemfiles/rails6.gemfile +0 -30
  99. data/gemfiles/rails6_1.gemfile +0 -30
  100. data/gemspecs/arel_extensions-v1.gemspec +0 -28
  101. data/gemspecs/arel_extensions-v2.gemspec +0 -28
  102. data/generate_gems.sh +0 -15
  103. data/lib/arel_extensions/nodes/aggregate_function.rb +0 -13
  104. data/lib/arel_extensions/nodes/sum.rb +0 -7
  105. data/lib/arel_extensions/visitors/convert_format.rb +0 -37
  106. data/test/arelx_test_helper.rb +0 -26
  107. data/version_v1.rb +0 -3
  108. data/version_v2.rb +0 -3
@@ -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,7 +0,0 @@
1
- module ArelExtensions
2
- module Nodes
3
- class Sum < AggregateFunction
4
- RETURN_TYPE = :number
5
- end
6
- end
7
- 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
@@ -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
@@ -1,3 +0,0 @@
1
- module ArelExtensions
2
- VERSION = "1.2.23".freeze
3
- end
data/version_v2.rb DELETED
@@ -1,3 +0,0 @@
1
- module ArelExtensions
2
- VERSION = "2.0.20".freeze
3
- end