groovy 0.4.0 → 0.4.1

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: 1019bd31fda4785bec67322dfb8aeddfab4d0fa12143b23a8dd75f4a3c84515e
4
- data.tar.gz: 44ab6a5fd87d136bc3b6915ab323fac95b6a8012f5cdc4ea2fb6498d5236cb3a
3
+ metadata.gz: b64b5151ebc9ad89b92fac064613d778e067449e11eb0c87cbf8ce40ca5e2630
4
+ data.tar.gz: 3e95ca4bac3946bcf79805c174216be0cb2870c06e47369056054bfb4d61a637
5
5
  SHA512:
6
- metadata.gz: 2ae8f4bcfb8d6166fa4ad8814521c498a44f3e512de23c4cb986d7ce7cd4ef98722a889c3a8e69e1f55bdfc9651f19a9b03e9d31bcb2f87552c73c194fc8f099
7
- data.tar.gz: 4a29d7007af10d67f4265ef9e431fa347ebc979745c87037fbf8957e2441fc012904cf5385d8aad8d1da6708e91ffae6b407acecf6e3c8e19f2f0bc787d90639
6
+ metadata.gz: 3320e1c8e3d31b9d48c2fbf409f2688b3be16734eebd631b9ee44f9509934968079b9ed1ab14a02422a559865e2619da1954640feed825bc17b8865ab96ac4d1
7
+ data.tar.gz: 1d1ebb476d22fa504a2b1f7ef7585f298fb5fbc84dbdc22cb34997c1a8e57032622e0c12867aab730bf75f08293d7f093a49059efb68d11c150be5684e4c9c34
@@ -9,6 +9,7 @@ class Product
9
9
  schema do |t|
10
10
  t.string :name
11
11
  t.integer :price
12
+ t.boolean :published
12
13
  t.timestamps
13
14
  end
14
15
 
@@ -19,11 +20,11 @@ end
19
20
  def populate
20
21
  5_000.times do |i|
21
22
  puts "Creating product #{i}" if i % 1000 == 0
22
- Product.create!(name: "A product with index #{i}", price: 10000 + i % 10)
23
+ Product.create!(name: "A product with index #{i}", published: true, price: 10000 + i % 10)
23
24
  end
24
25
  end
25
26
 
26
- populate if Product.count == 0
27
+ populate if Product.count == 0
27
28
 
28
29
  # 50_000 products: 50M
29
30
  # 100_000 products: 50M
@@ -34,6 +34,7 @@ class Place
34
34
  t.reference :categories, "Categories", type: :vector
35
35
  t.string :name
36
36
  t.string :description, index: true
37
+ t.boolean :visible
37
38
  t.timestamps
38
39
  end
39
40
 
@@ -404,12 +404,11 @@ module Groovy
404
404
  private
405
405
 
406
406
  def get_record_attribute(key)
407
- if val = record[key]
408
- if self.class.schema.time_column?(key)
409
- fix_time_value(val)
410
- else
411
- val
412
- end
407
+ val = record[key]
408
+ if self.class.schema.time_column?(key)
409
+ fix_time_value(val)
410
+ else
411
+ val
413
412
  end
414
413
  end
415
414
 
@@ -85,7 +85,7 @@ module Groovy
85
85
  add_param(AND + str)
86
86
 
87
87
  else
88
- str = val.nil? || val == false || val.to_s.strip == '' ? '\\' : escape_val(val)
88
+ str = val.nil? || val === false || val.to_s.strip == '' ? "\"\"" : escape_val(val)
89
89
  add_param(AND + [key, str].join(':'))
90
90
  end
91
91
  end
@@ -119,7 +119,7 @@ module Groovy
119
119
  add_param(AND + str)
120
120
 
121
121
  else
122
- str = val.nil? || val == false || val.to_s.strip == '' ? '\\' : escape_val(val)
122
+ str = val.nil? || val === false || val.to_s.strip == '' ? "\"\"" : escape_val(val)
123
123
  add_param(AND + [key, str].join(':!')) # not
124
124
  end
125
125
  end
@@ -232,12 +232,8 @@ module Groovy
232
232
  attr_reader :model, :table, :options
233
233
 
234
234
  def add_param(param)
235
- if parameters.include?(param)
236
- raise "Duplicate param: #{param}"
237
- end
238
-
239
- # if param matches blank/nil, put at the end of the stack
240
- param[/:\!?\\/] ? parameters.push(param) : parameters.unshift(param)
235
+ raise "Duplicate param: #{param}" if parameters.include?(param)
236
+ parameters.push(param)
241
237
  end
242
238
 
243
239
  def results
@@ -1,3 +1,3 @@
1
1
  module Groovy
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.4.1'.freeze
3
3
  end
@@ -40,6 +40,13 @@ describe Groovy::Query do
40
40
  res = TestProduct.where(tag_list: nil)
41
41
  expect(res.map(&:id)).to eq([@p3.id, @p5.id])
42
42
  end
43
+ it 'works with other nil values too' do
44
+ res = TestProduct.where(visible: nil).where(tag_list: nil)
45
+ expect(res.map(&:id)).to eq([])
46
+
47
+ res = TestProduct.where(tag_list: nil).where(name: nil)
48
+ expect(res.map(&:id)).to eq([])
49
+ end
43
50
  it 'works with other args too' do
44
51
  res = TestProduct.where(name: 'Product 5').where(tag_list: nil)
45
52
  expect(res.map(&:id)).to eq([@p5.id])
@@ -187,6 +194,13 @@ describe Groovy::Query do
187
194
  res = TestProduct.where.not(tag_list: nil)
188
195
  expect(res.map(&:id)).to eq([@p1.id, @p2.id, @p4.id])
189
196
  end
197
+ it 'works with other nil values too' do
198
+ res = TestProduct.where.not(visible: nil).where(tag_list: nil)
199
+ expect(res.map(&:id)).to eq([@p3.id, @p5.id])
200
+
201
+ res = TestProduct.where.not(tag_list: nil).where(name: nil)
202
+ expect(res.map(&:id)).to eq([])
203
+ end
190
204
  it 'works with other args too' do
191
205
  res = TestProduct.where.not(name: 'Product 2').where.not(tag_list: nil)
192
206
  expect(res.map(&:id)).to eq([@p1.id, @p4.id])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groovy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomás Pollak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-09 00:00:00.000000000 Z
11
+ date: 2020-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rroonga