arel-extensions 6.0.0.6 → 6.0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8b1c993b347393ad06a933f8ab1c8b1e315d7f39c5921ad21c995538a3fc64c
4
- data.tar.gz: 32e7728efa400fd618557a39ddabdb4b4e2ec01fbb8e220053d2e6f228a103c2
3
+ metadata.gz: 87c1e3d344cef64601be578c9efa5e05ca8a0fb2a0443cb81f586c06a3e1009f
4
+ data.tar.gz: 361a92b9257df496481556ccb63f78e399168dc021a5461f5a3b5b4e324a401e
5
5
  SHA512:
6
- metadata.gz: 7d35be931c9fa7e39f1265b11851d034da64d49f8e2c30d457208dcc4d66991bec244590087bd20ff0127cb8a12966fa654a7cf78ad881280031215f0baa1c7d
7
- data.tar.gz: 0eb34be84a36821aaa96ef5a15e0de64d703194c1764c37981fb862952683cfb56218c12ce4be81bdf977c118dcc6560a40fce9be68413cb99385ed057730f52
6
+ metadata.gz: 4e83c72da829bf31e4113d777f4cede440c1ecb8d3ad7c552225978788956af72030c669b782aa935cc4945990bb02449c224e582643ed8e88694d4b439a1995
7
+ data.tar.gz: ade28f1b9fad88a81eeeb0d25a7a3608900c802858f0579a9f0713dd68a655433ce2c2f4504939c83600db20e77e4a28995feb2bd0db2573772c4ba762f00372
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  .DS_Store
2
2
  *.gem
3
+ Gemfile.lock
@@ -8,14 +8,13 @@ cache:
8
8
  - /home/travis/.rvm/gems
9
9
 
10
10
  rvm:
11
- - 2.5
12
11
  - 2.6
13
12
 
14
13
  env:
15
14
  matrix:
16
- - RAILS_VERSION=v6.0.0 GEM=activerecord:mysql2
17
- - RAILS_VERSION=v6.0.0 GEM=activerecord:sqlite3
18
- - RAILS_VERSION=v6.0.0 GEM=activerecord:postgresql
15
+ - RAILS_VERSION=v6.0.3.1 GEM=activerecord:mysql2
16
+ - RAILS_VERSION=v6.0.3.1 GEM=activerecord:sqlite3
17
+ - RAILS_VERSION=v6.0.3.1 GEM=activerecord:postgresql
19
18
 
20
19
  services:
21
20
  - mysql
@@ -26,6 +25,7 @@ before_install:
26
25
  - unset BUNDLE_GEMFILE
27
26
  - gem update --system
28
27
  - gem update bundler
28
+ - gem install bundler -v 1.17.3
29
29
 
30
30
  install:
31
31
  - git clone https://github.com/rails/rails.git ~/build/rails
@@ -37,7 +37,7 @@ install:
37
37
  - "sed -i \"/group :db do/a gem 'arel-extensions', require: 'arel/extensions', path: File.expand_path\\('~\\/build\\/malomalo\\/arel-extensions'\\)\" ~/build/rails/Gemfile"
38
38
  - sed -i "/rb-inotify/d" ~/build/rails/Gemfile
39
39
  - cat ~/build/rails/Gemfile
40
- - bundle install --jobs=3 --retry=3
40
+ - bundle install --jobs=3 --retry=3 --full-index
41
41
  - popd
42
42
 
43
43
  script:
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'arel-extensions'
3
- gem.version = '6.0.0.6'
3
+ gem.version = '6.0.0.8'
4
4
  gem.authors = ["Jon Bracy"]
5
5
  gem.email = ["jonbracy@gmail.com"]
6
6
  gem.summary = %q{Adds support for missing SQL operators and functions to Arel}
@@ -25,7 +25,11 @@ module Arel
25
25
  self.name == other.name &&
26
26
  self.collection == other.collection
27
27
  end
28
-
28
+
29
+ def type_cast_for_database(value)
30
+ relation.type_cast_for_database(value)
31
+ end
32
+
29
33
  end
30
34
  end
31
35
  end
@@ -2,11 +2,11 @@ module Arel
2
2
  module TSPredications
3
3
 
4
4
  def ts_query(expression, language=nil)
5
- vector = Arel::Nodes::TSVector.new(self, language)
6
- query = Arel::Nodes::TSQuery.new(expression, language)
5
+ vector = Arel::Nodes::TSVector.new(self, language: language)
6
+ query = Arel::Nodes::TSQuery.new(expression, language: language)
7
7
 
8
8
  Arel::Nodes::TSMatch.new(vector, query)
9
9
  end
10
10
 
11
11
  end
12
- end
12
+ end
@@ -6,30 +6,42 @@ module Arel
6
6
  def visit_Arel_Nodes_Ascending o, collector
7
7
  hash = visit(o.expr, collector)
8
8
 
9
- case o.nulls
9
+ value = case o.nulls
10
10
  when :nulls_first
11
- add_to_bottom_of_hash_or_array(hash, {asc: :nulls_first})
11
+ {asc: :nulls_first}
12
12
  when :nulls_last
13
- add_to_bottom_of_hash_or_array(hash, {asc: :nulls_last})
13
+ {asc: :nulls_last}
14
14
  else
15
- add_to_bottom_of_hash_or_array(hash, :asc)
15
+ :asc
16
16
  end
17
17
 
18
+ if hash.is_a?(Hash)
19
+ add_to_bottom_of_hash_or_array(hash, value)
20
+ else
21
+ hash = { hash => value }
22
+ end
23
+
18
24
  hash
19
25
  end
20
26
 
21
27
  def visit_Arel_Nodes_Descending o, collector
22
28
  hash = visit(o.expr, collector)
23
-
24
- case o.nulls
29
+
30
+ value = case o.nulls
25
31
  when :nulls_first
26
- add_to_bottom_of_hash_or_array(hash, {desc: :nulls_first})
32
+ {desc: :nulls_first}
27
33
  when :nulls_last
28
- add_to_bottom_of_hash_or_array(hash, {desc: :nulls_last})
34
+ {desc: :nulls_last}
29
35
  else
30
- add_to_bottom_of_hash_or_array(hash, :desc)
36
+ :desc
31
37
  end
32
-
38
+
39
+ if hash.is_a?(Hash)
40
+ add_to_bottom_of_hash_or_array(hash, value)
41
+ else
42
+ hash = { hash => value }
43
+ end
44
+
33
45
  hash
34
46
  end
35
47
 
@@ -97,5 +97,53 @@ class SunstoneTest < ActiveSupport::TestCase
97
97
  # SQL
98
98
  # end
99
99
 
100
+ test '::order(column.asc)' do
101
+ query = SunstoneProperty.order(SunstoneProperty.arel_table[:id].asc)
102
+ assert_sar(query, 'GET', '/sunstone_properties', {
103
+ order: [{ id: :asc }]
104
+ })
105
+ end
106
+
107
+ test '::order(column1.asc, column2.asc)' do
108
+ query = SunstoneProperty.order(SunstoneProperty.arel_table[:id].asc, SunstoneProperty.arel_table[:name].asc)
109
+ assert_sar(query, 'GET', '/sunstone_properties', {
110
+ order: [{ id: :asc }, { name: :asc }]
111
+ })
112
+ end
113
+
114
+ test '::order(column.desc)' do
115
+ query = SunstoneProperty.order(SunstoneProperty.arel_table[:id].desc)
116
+ assert_sar(query, 'GET', '/sunstone_properties', {
117
+ order: [{ id: :desc }]
118
+ })
119
+ end
120
+
121
+ test '::order(column.asc(:nulls_first))' do
122
+ query = SunstoneProperty.order(SunstoneProperty.arel_table[:id].asc(:nulls_first))
123
+ assert_sar(query, 'GET', '/sunstone_properties', {
124
+ order: [{ id: { asc: :nulls_first } }]
125
+ })
126
+ end
127
+
128
+ test '::order(column.asc(:nulls_last))' do
129
+ query = SunstoneProperty.order(SunstoneProperty.arel_table[:id].asc(:nulls_last))
130
+ assert_sar(query, 'GET', '/sunstone_properties', {
131
+ order: [{ id: { asc: :nulls_last } }]
132
+ })
133
+ end
134
+
135
+ test '::order(column.desc(:nulls_first))' do
136
+ query = SunstoneProperty.order(SunstoneProperty.arel_table[:id].desc(:nulls_first))
137
+ assert_sar(query, 'GET', '/sunstone_properties', {
138
+ order: [{ id: { desc: :nulls_first } }]
139
+ })
140
+ end
141
+
142
+ test '::order(column.desc(:nulls_last))' do
143
+ query = SunstoneProperty.order(SunstoneProperty.arel_table[:id].desc(:nulls_last))
144
+ assert_sar(query, 'GET', '/sunstone_properties', {
145
+ order: [{ id: { desc: :nulls_last } }]
146
+ })
147
+ end
100
148
 
101
149
  end
@@ -180,7 +180,11 @@ class ActiveSupport::TestCase
180
180
  assert_equal method, sar.method
181
181
  assert_equal path, sar.path.split('?').first
182
182
  assert_equal deep_transform_query(query_params), MessagePack.unpack(CGI::unescape(sar.path.split('?').last))
183
- assert_equal body, sar.body
183
+ if body.nil?
184
+ assert_nil sar.body
185
+ else
186
+ assert_equal body, sar.body
187
+ end
184
188
  end
185
189
 
186
190
  def assert_sql(expected, query)
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.0.0.6
4
+ version: 6.0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Bracy
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-11 00:00:00.000000000 Z
11
+ date: 2020-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -136,7 +136,7 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- description:
139
+ description:
140
140
  email:
141
141
  - jonbracy@gmail.com
142
142
  executables: []
@@ -146,7 +146,6 @@ files:
146
146
  - ".gitignore"
147
147
  - ".travis.yml"
148
148
  - Gemfile
149
- - Gemfile.lock
150
149
  - LICENSE
151
150
  - README.md
152
151
  - Rakefile
@@ -190,7 +189,7 @@ homepage: https://github.com/malomalo/arel-extensions
190
189
  licenses:
191
190
  - MIT
192
191
  metadata: {}
193
- post_install_message:
192
+ post_install_message:
194
193
  rdoc_options: []
195
194
  require_paths:
196
195
  - lib
@@ -205,8 +204,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
204
  - !ruby/object:Gem::Version
206
205
  version: '0'
207
206
  requirements: []
208
- rubygems_version: 3.0.3
209
- signing_key:
207
+ rubygems_version: 3.1.2
208
+ signing_key:
210
209
  specification_version: 4
211
210
  summary: Adds support for missing SQL operators and functions to Arel
212
211
  test_files:
@@ -1,73 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- arel-extensions (6.0.0.5)
5
- activerecord (>= 6.0.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (6.0.0)
11
- activesupport (= 6.0.0)
12
- activerecord (6.0.0)
13
- activemodel (= 6.0.0)
14
- activesupport (= 6.0.0)
15
- activesupport (6.0.0)
16
- concurrent-ruby (~> 1.0, >= 1.0.2)
17
- i18n (>= 0.7, < 2)
18
- minitest (~> 5.1)
19
- tzinfo (~> 1.1)
20
- zeitwerk (~> 2.1, >= 2.1.8)
21
- addressable (2.7.0)
22
- public_suffix (>= 2.0.2, < 5.0)
23
- ansi (1.5.0)
24
- builder (3.2.3)
25
- concurrent-ruby (1.1.5)
26
- cookie_store (0.1.4)
27
- crack (0.4.3)
28
- safe_yaml (~> 1.0.0)
29
- hashdiff (1.0.0)
30
- i18n (1.6.0)
31
- concurrent-ruby (~> 1.0)
32
- minitest (5.11.3)
33
- minitest-reporters (1.3.8)
34
- ansi
35
- builder
36
- minitest (>= 5.0)
37
- ruby-progressbar
38
- msgpack (1.3.1)
39
- pg (1.1.4)
40
- public_suffix (4.0.1)
41
- rake (12.3.3)
42
- rgeo (2.1.0)
43
- ruby-progressbar (1.10.1)
44
- safe_yaml (1.0.5)
45
- sunstone (6.0.0.5)
46
- activerecord (>= 6.0.0.rc1)
47
- cookie_store
48
- msgpack
49
- thread_safe (0.3.6)
50
- tzinfo (1.2.5)
51
- thread_safe (~> 0.1)
52
- webmock (3.7.6)
53
- addressable (>= 2.3.6)
54
- crack (>= 0.3.2)
55
- hashdiff (>= 0.4.0, < 2.0.0)
56
- zeitwerk (2.1.10)
57
-
58
- PLATFORMS
59
- ruby
60
-
61
- DEPENDENCIES
62
- arel-extensions!
63
- bundler
64
- minitest
65
- minitest-reporters
66
- pg
67
- rake
68
- rgeo
69
- sunstone
70
- webmock
71
-
72
- BUNDLED WITH
73
- 1.17.3