ohm 3.0.2 → 3.0.3

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
  SHA1:
3
- metadata.gz: f4d772d265943ece2cb2474ffffe91ca507ea015
4
- data.tar.gz: e12bcab718e57af58ecd4084db153d22bc17158a
3
+ metadata.gz: 94a422b709084441dabd2d9c04a38014ec6ddbef
4
+ data.tar.gz: 8549e0842a0737e65a5d459f483b1002e8914ecf
5
5
  SHA512:
6
- metadata.gz: e64574ab2442f7bce423f4545fe2e07bf029533e8e6a10eb56d2f86642d48e94d0b36e9f076f9658adc57fda1f9f9cf803b88209b8c5cdce63182238cfb85eea
7
- data.tar.gz: 2e9378f29c6f884c8b28f19d94ca208188a06b1324898d2bec0d2a63da2d14c8e85224a5aec34be90e7c0007ee59080fdbf827e2434cd7325efd3ef2ef51890e
6
+ metadata.gz: 404357ab09aa51976a53ddc7fe43a31b29030f6067386daca0787fe8cd7d6cb1dbb80fabaee8c839aa23d576f9772dc66584df17e27c37317392aed7ac7f1927
7
+ data.tar.gz: 5cffd617b9e7e3119d1dc2d1f241a1107bafd7bdb7b53d4e78745e9d7f1570ceb1c887d488353c9d15782da0c27b750987299c321bb770e0e2eaf34326fb4d84
@@ -1,3 +1,10 @@
1
+ ## 3.0.3
2
+
3
+ - Fix bug that gave false positives for unique indices.
4
+
5
+ Uniques were indexed for nil values as empty strings. This
6
+ release fixes that issue.
7
+
1
8
  ## 3.0.2
2
9
 
3
10
  - Fix bug created the wrong keys when indexing floats.
data/lib/ohm.rb CHANGED
@@ -1334,10 +1334,16 @@ module Ohm
1334
1334
  #
1335
1335
  def save
1336
1336
  indices = {}
1337
- model.indices.each { |field| indices[field] = Array(send(field)).map(&:to_s) }
1337
+ model.indices.each do |field|
1338
+ next unless (value = send(field))
1339
+ indices[field] = Array(value).map(&:to_s)
1340
+ end
1338
1341
 
1339
1342
  uniques = {}
1340
- model.uniques.each { |field| uniques[field] = send(field).to_s }
1343
+ model.uniques.each do |field|
1344
+ next unless (value = send(field))
1345
+ uniques[field] = value.to_s
1346
+ end
1341
1347
 
1342
1348
  features = {
1343
1349
  "name" => model.name
@@ -1367,7 +1373,10 @@ module Ohm
1367
1373
  #
1368
1374
  def delete
1369
1375
  uniques = {}
1370
- model.uniques.each { |field| uniques[field] = send(field) }
1376
+ model.uniques.each do |field|
1377
+ next unless (value = send(field))
1378
+ uniques[field] = value.to_s
1379
+ end
1371
1380
 
1372
1381
  script(LUA_DELETE, 0,
1373
1382
  { "name" => model.name,
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "ohm"
3
- s.version = "3.0.2"
3
+ s.version = "3.0.3"
4
4
  s.summary = %{Object-hash mapping library for Redis.}
5
5
  s.description = %Q{Ohm is a library that allows to store an object in Redis, a persistent key-value database. It has very good performance.}
6
6
  s.authors = ["Michel Martens", "Damian Janowski", "Cyril David"]
@@ -96,3 +96,13 @@ test "unique virtual attribute" do
96
96
  User.create(:email => "baz@yahoo.com")
97
97
  end
98
98
  end
99
+
100
+ test "nil doesn't count for uniques" do
101
+ u1 = User.create
102
+ u2 = User.create
103
+
104
+ assert u1.id
105
+ assert u2.id
106
+
107
+ assert u1.id != u2.id
108
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohm
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Martens
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-04-22 00:00:00.000000000 Z
13
+ date: 2016-06-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: redic