arel-extensions 6.0.0.9 → 6.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +34 -11
- data/arel-extensions.gemspec +7 -4
- data/lib/arel/array_predications.rb +4 -14
- data/lib/arel/extensions.rb +0 -2
- data/lib/arel/extensions/version.rb +5 -0
- data/lib/arel/visitors/postgresql_extensions.rb +0 -14
- data/test/database.rb +7 -9
- data/test/sunstone_test.rb +1 -1
- data/test/test_helper.rb +10 -10
- metadata +23 -10
- data/lib/arel/nodes/contains.rb +0 -6
- data/lib/arel/nodes/overlaps.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6499ad3b57ef7119b545163cecc1972913c494d57bbfd19c81aecbbf74219880
|
4
|
+
data.tar.gz: 576fb2e56d087957430ff9e8cc5ee3dc968c2f17ba3d2c617a4eae2f6664f340
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df8347481c7c0d86903d7f0fe35850da0ac725325ab18f11191f6c04455d88515cd47306ab1fb972f5ca2e8a49e678cbfd242c12a0850575a5cdbde95bb41a9b
|
7
|
+
data.tar.gz: 52c2e805c1758594478b229c421ba301571c82d715be1904f8fd00359ab7b399919d2d6f74c8548078ad141c41a7bc687d7d311b33f79ac171ca38f95859623f
|
data/.travis.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
dist:
|
1
|
+
dist: bionic
|
2
2
|
language: ruby
|
3
3
|
sudo: false
|
4
4
|
|
@@ -8,37 +8,60 @@ cache:
|
|
8
8
|
- /home/travis/.rvm/gems
|
9
9
|
|
10
10
|
rvm:
|
11
|
-
- 2.
|
11
|
+
- 2.7
|
12
12
|
|
13
13
|
env:
|
14
14
|
matrix:
|
15
|
-
- RAILS_VERSION=v6.0
|
16
|
-
- RAILS_VERSION=v6.0
|
17
|
-
- RAILS_VERSION=v6.0
|
15
|
+
- RAILS_VERSION=v6.1.0 TASK='db:mysql:rebuild mysql2:test'
|
16
|
+
- RAILS_VERSION=v6.1.0 TASK='db:mysql:rebuild mysql2:isolated_test'
|
17
|
+
- RAILS_VERSION=v6.1.0 TASK='db:postgresql:rebuild postgresql:test'
|
18
|
+
- RAILS_VERSION=v6.1.0 TASK='db:postgresql:rebuild postgresql:isolated_test'
|
19
|
+
- RAILS_VERSION=v6.1.0 TASK='sqlite3:test'
|
20
|
+
- RAILS_VERSION=v6.1.0 TASK='sqlite3:isolated_test'
|
21
|
+
- RAILS_VERSION=v6.1.0 TASK='sqlite3_mem:test'
|
18
22
|
|
19
23
|
services:
|
20
24
|
- mysql
|
21
25
|
addons:
|
22
|
-
postgresql: "
|
26
|
+
postgresql: "13"
|
27
|
+
apt:
|
28
|
+
packages:
|
29
|
+
- postgresql-13
|
30
|
+
- postgresql-client-13
|
23
31
|
|
24
32
|
before_install:
|
33
|
+
- sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/13/main/postgresql.conf
|
34
|
+
- sudo cp /etc/postgresql/{9.3,13}/main/pg_hba.conf
|
35
|
+
- sudo pg_ctlcluster 13 main restart
|
25
36
|
- unset BUNDLE_GEMFILE
|
26
37
|
- gem update --system
|
27
38
|
- gem update bundler
|
28
|
-
- gem install bundler
|
39
|
+
- gem install bundler --version 1.17.3
|
40
|
+
- mysql -e "create user rails@localhost;"
|
41
|
+
- mysql -e "grant all privileges on activerecord_unittest.* to rails@localhost;"
|
42
|
+
- mysql -e "grant all privileges on activerecord_unittest2.* to rails@localhost;"
|
43
|
+
- mysql -e "grant all privileges on inexistent_activerecord_unittest.* to rails@localhost;"
|
44
|
+
- mysql -e "create database activerecord_unittest default character set utf8mb4;"
|
45
|
+
- mysql -e "create database activerecord_unittest2 default character set utf8mb4;"
|
29
46
|
|
30
47
|
install:
|
31
|
-
- git clone https://github.com/rails/rails.git ~/build/rails
|
48
|
+
- git clone --branch $RAILS_VERSION https://github.com/rails/rails.git ~/build/rails
|
49
|
+
|
50
|
+
before_script:
|
51
|
+
- sed -i "s/t.warning = true/t.warning = false/g" Rakefile
|
32
52
|
- pushd ~/build/rails
|
33
|
-
- git
|
53
|
+
- git status
|
34
54
|
- sed -i "s/Gem.ruby, '-w'/Gem.ruby, '-w0'/" ~/build/rails/activerecord/Rakefile
|
35
55
|
- sed -i "s/t.warning = true/t.warning = false/g" ~/build/rails/activerecord/Rakefile
|
36
56
|
- sed -i "/require 'support\/connection'/a \$LOAD_PATH.unshift\(File.expand_path\('~\/build\/malomalo\/arel-extensions\/lib'\)\)\nrequire 'arel/extensions'" ~/build/rails/activerecord/test/cases/helper.rb
|
37
57
|
- "sed -i \"/group :db do/a gem 'arel-extensions', require: 'arel/extensions', path: File.expand_path\\('~\\/build\\/malomalo\\/arel-extensions'\\)\" ~/build/rails/Gemfile"
|
38
58
|
- sed -i "/rb-inotify/d" ~/build/rails/Gemfile
|
39
59
|
- cat ~/build/rails/Gemfile
|
40
|
-
-
|
60
|
+
- rm ~/build/rails/Gemfile.lock
|
61
|
+
- bundle update --jobs=3 --retry=3
|
41
62
|
- popd
|
63
|
+
- bundle install --jobs=3 --retry=3
|
42
64
|
|
43
65
|
script:
|
44
|
-
-
|
66
|
+
- bundle exec rake test
|
67
|
+
- cd ~/build/rails/activerecord && bundle exec rake $TASK
|
data/arel-extensions.gemspec
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
require File.expand_path("../lib/arel/extensions/version", __FILE__)
|
2
|
+
|
1
3
|
Gem::Specification.new do |gem|
|
2
4
|
gem.name = 'arel-extensions'
|
3
|
-
gem.version =
|
5
|
+
gem.version = Arel::Extensions::VERSION
|
4
6
|
gem.authors = ["Jon Bracy"]
|
5
7
|
gem.email = ["jonbracy@gmail.com"]
|
6
8
|
gem.summary = %q{Adds support for missing SQL operators and functions to Arel}
|
@@ -11,15 +13,16 @@ Gem::Specification.new do |gem|
|
|
11
13
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
12
14
|
gem.require_paths = ["lib"]
|
13
15
|
|
14
|
-
gem.add_dependency 'activerecord', '>= 6.
|
16
|
+
gem.add_dependency 'activerecord', '>= 6.1.0'
|
15
17
|
|
16
18
|
gem.add_development_dependency "bundler"
|
19
|
+
gem.add_development_dependency "byebug"
|
17
20
|
gem.add_development_dependency "rake"
|
18
21
|
gem.add_development_dependency 'minitest'
|
19
22
|
gem.add_development_dependency 'minitest-reporters'
|
20
|
-
gem.add_development_dependency "sunstone"
|
23
|
+
gem.add_development_dependency "sunstone", '>= 6.1.0.rc1'
|
21
24
|
gem.add_development_dependency "webmock"
|
22
25
|
gem.add_development_dependency 'pg'
|
23
26
|
gem.add_development_dependency 'rgeo'
|
24
|
-
|
27
|
+
|
25
28
|
end
|
@@ -1,24 +1,14 @@
|
|
1
1
|
module Arel
|
2
2
|
module ArrayPredications
|
3
|
-
|
4
|
-
# Used by both JSON and ARRAY so it doesn't try to cast to array
|
5
|
-
def contains(value)
|
6
|
-
Arel::Nodes::Contains.new(self, value)
|
7
|
-
end
|
8
|
-
|
3
|
+
|
9
4
|
# Used by both JSON and ARRAY so it doesn't try to cast to array
|
10
5
|
def contained_by(value)
|
11
6
|
Arel::Nodes::ContainedBy.new(self, value)
|
12
7
|
end
|
13
|
-
|
8
|
+
|
14
9
|
def excludes(value)
|
15
10
|
Arel::Nodes::Excludes.new(self, value)
|
16
11
|
end
|
17
|
-
|
18
|
-
def overlaps(*values)
|
19
|
-
values = values[0] if values.size == 1 && values[0].is_a?(Array)
|
20
|
-
Arel::Nodes::Overlaps.new(self, values)
|
21
|
-
end
|
22
|
-
|
12
|
+
|
23
13
|
end
|
24
|
-
end
|
14
|
+
end
|
data/lib/arel/extensions.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require "arel"
|
2
2
|
require File.expand_path('../nodes/hex_encoded_binary', __FILE__)
|
3
3
|
|
4
|
-
require File.expand_path('../nodes/overlaps', __FILE__)
|
5
|
-
require File.expand_path('../nodes/contains', __FILE__)
|
6
4
|
require File.expand_path('../nodes/within', __FILE__)
|
7
5
|
require File.expand_path('../nodes/excludes', __FILE__)
|
8
6
|
require File.expand_path('../nodes/contained_by', __FILE__)
|
@@ -28,13 +28,6 @@ module Arel
|
|
28
28
|
collector << "RANDOM()"
|
29
29
|
end
|
30
30
|
|
31
|
-
def visit_Arel_Nodes_Contains o, collector
|
32
|
-
visit o.left, collector
|
33
|
-
collector << ' @> '
|
34
|
-
collector << quote(o.left.type_cast_for_database(o.right))
|
35
|
-
collector
|
36
|
-
end
|
37
|
-
|
38
31
|
def visit_Arel_Nodes_ContainedBy o, collector
|
39
32
|
visit o.left, collector
|
40
33
|
collector << ' <@ '
|
@@ -51,13 +44,6 @@ module Arel
|
|
51
44
|
collector
|
52
45
|
end
|
53
46
|
|
54
|
-
def visit_Arel_Nodes_Overlaps o, collector
|
55
|
-
visit o.left, collector
|
56
|
-
collector << ' && '
|
57
|
-
collector << quote(o.left.type_cast_for_database(o.right))
|
58
|
-
collector
|
59
|
-
end
|
60
|
-
|
61
47
|
def visit_Arel_Attributes_Key(o, collector, last_key = true)
|
62
48
|
if o.relation.is_a?(Arel::Attributes::Key)
|
63
49
|
visit_Arel_Attributes_Key(o.relation, collector, false)
|
data/test/database.rb
CHANGED
@@ -1,16 +1,14 @@
|
|
1
|
-
task = ActiveRecord::Tasks::PostgreSQLDatabaseTasks.new({
|
2
|
-
'adapter' => 'postgresql',
|
3
|
-
'database' => "arel-extensions-test"
|
4
|
-
})
|
5
|
-
task.drop
|
6
|
-
task.create
|
7
|
-
|
8
1
|
ActiveRecord::Base.establish_connection({
|
9
2
|
adapter: "postgresql",
|
10
3
|
database: "arel-extensions-test",
|
11
4
|
encoding: "utf8"
|
12
5
|
})
|
13
6
|
|
7
|
+
db_config = ActiveRecord::Base.connection_db_config
|
8
|
+
task = ActiveRecord::Tasks::PostgreSQLDatabaseTasks.new(db_config)
|
9
|
+
task.drop
|
10
|
+
task.create
|
11
|
+
|
14
12
|
ActiveRecord::Migration.suppress_messages do
|
15
13
|
ActiveRecord::Schema.define do
|
16
14
|
|
@@ -18,7 +16,7 @@ ActiveRecord::Migration.suppress_messages do
|
|
18
16
|
t.integer "name"
|
19
17
|
t.integer "property_id"
|
20
18
|
end
|
21
|
-
|
19
|
+
|
22
20
|
create_table "properties", force: :cascade do |t|
|
23
21
|
t.string "name", limit: 255
|
24
22
|
t.tsvector 'vector_col'
|
@@ -48,4 +46,4 @@ class SunstoneProperty < SunstoneRecord
|
|
48
46
|
has_many :addresses, class_name: 'SunstoneAddress'
|
49
47
|
end
|
50
48
|
|
51
|
-
SunstoneRecord.establish_connection(adapter: 'sunstone',
|
49
|
+
SunstoneRecord.establish_connection(adapter: 'sunstone', endpoint: 'http://example.com')
|
data/test/sunstone_test.rb
CHANGED
@@ -27,7 +27,7 @@ class SunstoneTest < ActiveSupport::TestCase
|
|
27
27
|
# end
|
28
28
|
|
29
29
|
test "::filter json_column: {contains: JSON_HASH}" do
|
30
|
-
query = SunstoneProperty.where(SunstoneProperty.
|
30
|
+
query = SunstoneProperty.where(SunstoneProperty.arel_table['metadata'].contains({json: 'string'}))
|
31
31
|
assert_sar(query, 'GET', '/sunstone_properties', {
|
32
32
|
where: {metadata: {contains: { json: 'string' }}}
|
33
33
|
})
|
data/test/test_helper.rb
CHANGED
@@ -30,7 +30,7 @@ $debugging = false
|
|
30
30
|
# File 'lib/active_support/testing/declarative.rb', somewhere in rails....
|
31
31
|
class ActiveSupport::TestCase
|
32
32
|
include WebMock::API
|
33
|
-
|
33
|
+
|
34
34
|
# File 'lib/active_support/testing/declarative.rb'
|
35
35
|
def self.test(name, &block)
|
36
36
|
test_name = "test_#{name.gsub(/\s+/, '_')}".to_sym
|
@@ -44,7 +44,7 @@ class ActiveSupport::TestCase
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
def webmock(method, path, query=nil)
|
49
49
|
query = deep_transform_query(query) if query
|
50
50
|
|
@@ -56,7 +56,7 @@ class ActiveSupport::TestCase
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
def setup
|
61
61
|
sunstone_schema = {
|
62
62
|
addresses: {
|
@@ -74,7 +74,7 @@ class ActiveSupport::TestCase
|
|
74
74
|
}
|
75
75
|
}
|
76
76
|
}
|
77
|
-
|
77
|
+
|
78
78
|
req_stub = stub_request(:get, /^http:\/\/example.com/).with do |req|
|
79
79
|
case req.uri.path
|
80
80
|
when '/tables'
|
@@ -85,7 +85,7 @@ class ActiveSupport::TestCase
|
|
85
85
|
false
|
86
86
|
end
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
req_stub.to_return do |req|
|
90
90
|
case req.uri.path
|
91
91
|
when '/tables'
|
@@ -151,7 +151,7 @@ class ActiveSupport::TestCase
|
|
151
151
|
unless ignore =~ sql
|
152
152
|
if $debugging
|
153
153
|
puts caller.select { |l| l.starts_with?(File.expand_path('../../lib', __FILE__)) }
|
154
|
-
puts "\n\n"
|
154
|
+
puts "\n\n"
|
155
155
|
end
|
156
156
|
end
|
157
157
|
self.class.log << sql unless ignore =~ sql
|
@@ -173,7 +173,7 @@ class ActiveSupport::TestCase
|
|
173
173
|
object
|
174
174
|
end
|
175
175
|
end
|
176
|
-
|
176
|
+
|
177
177
|
def assert_sar(query, method, path, query_params = {}, body = nil)
|
178
178
|
sar = query.to_sar
|
179
179
|
|
@@ -186,7 +186,7 @@ class ActiveSupport::TestCase
|
|
186
186
|
assert_equal body, sar.body
|
187
187
|
end
|
188
188
|
end
|
189
|
-
|
189
|
+
|
190
190
|
def assert_sql(expected, query)
|
191
191
|
assert_equal expected.strip, query.to_sql.strip.gsub(/\s+/, ' ')
|
192
192
|
end
|
@@ -205,5 +205,5 @@ class ActiveSupport::TestCase
|
|
205
205
|
alias :assert_not_predicate :refute_predicate
|
206
206
|
alias :assert_not_respond_to :refute_respond_to
|
207
207
|
alias :assert_not_same :refute_same
|
208
|
-
|
209
|
-
end
|
208
|
+
|
209
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arel-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.1.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Bracy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 6.
|
19
|
+
version: 6.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 6.
|
26
|
+
version: 6.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: byebug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +100,14 @@ dependencies:
|
|
86
100
|
requirements:
|
87
101
|
- - ">="
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
103
|
+
version: 6.1.0.rc1
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
110
|
+
version: 6.1.0.rc1
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: webmock
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,16 +172,15 @@ files:
|
|
158
172
|
- lib/arel/attributes/cast.rb
|
159
173
|
- lib/arel/attributes/key.rb
|
160
174
|
- lib/arel/extensions.rb
|
175
|
+
- lib/arel/extensions/version.rb
|
161
176
|
- lib/arel/gis_predications.rb
|
162
177
|
- lib/arel/json_predications.rb
|
163
178
|
- lib/arel/nodes/contained_by.rb
|
164
|
-
- lib/arel/nodes/contains.rb
|
165
179
|
- lib/arel/nodes/excludes.rb
|
166
180
|
- lib/arel/nodes/has_any_key.rb
|
167
181
|
- lib/arel/nodes/has_key.rb
|
168
182
|
- lib/arel/nodes/has_keys.rb
|
169
183
|
- lib/arel/nodes/hex_encoded_binary.rb
|
170
|
-
- lib/arel/nodes/overlaps.rb
|
171
184
|
- lib/arel/nodes/random.rb
|
172
185
|
- lib/arel/nodes/relation.rb
|
173
186
|
- lib/arel/nodes/ts_match.rb
|
@@ -200,9 +213,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
200
213
|
version: '0'
|
201
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
202
215
|
requirements:
|
203
|
-
- - "
|
216
|
+
- - ">"
|
204
217
|
- !ruby/object:Gem::Version
|
205
|
-
version:
|
218
|
+
version: 1.3.1
|
206
219
|
requirements: []
|
207
220
|
rubygems_version: 3.1.4
|
208
221
|
signing_key:
|
data/lib/arel/nodes/contains.rb
DELETED