ohm 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/lib/ohm.rb +3 -3
- data/lib/ohm/lua/save.lua +3 -3
- data/ohm.gemspec +1 -1
- data/test/indices.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4d772d265943ece2cb2474ffffe91ca507ea015
|
4
|
+
data.tar.gz: e12bcab718e57af58ecd4084db153d22bc17158a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e64574ab2442f7bce423f4545fe2e07bf029533e8e6a10eb56d2f86642d48e94d0b36e9f076f9658adc57fda1f9f9cf803b88209b8c5cdce63182238cfb85eea
|
7
|
+
data.tar.gz: 2e9378f29c6f884c8b28f19d94ca208188a06b1324898d2bec0d2a63da2d14c8e85224a5aec34be90e7c0007ee59080fdbf827e2434cd7325efd3ef2ef51890e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## 3.0.2
|
2
|
+
|
3
|
+
- Fix bug created the wrong keys when indexing floats.
|
4
|
+
|
5
|
+
As reported by @slowernet, if an indexed attribute was assigned a
|
6
|
+
real value with 0 fractional part (eg. 3.0), the `tostring` function
|
7
|
+
in lua truncated the value to an integer. As a result, the index
|
8
|
+
was created with the wrong key (Model:indices:attribute:3, instead
|
9
|
+
of Model:indices:attribute:3.0). The fix is to convert all values
|
10
|
+
to strings before sending them to the Lua script.
|
11
|
+
|
1
12
|
## 3.0.1
|
2
13
|
|
3
14
|
- Adapt Lua scripts to Redis unstable.
|
data/lib/ohm.rb
CHANGED
@@ -15,7 +15,7 @@ module Ohm
|
|
15
15
|
#
|
16
16
|
# MissingID:
|
17
17
|
#
|
18
|
-
# Comment.new.id # =>
|
18
|
+
# Comment.new.id # => nil
|
19
19
|
# Comment.new.key # => Error
|
20
20
|
#
|
21
21
|
# Solution: you need to save your model first.
|
@@ -1334,10 +1334,10 @@ module Ohm
|
|
1334
1334
|
#
|
1335
1335
|
def save
|
1336
1336
|
indices = {}
|
1337
|
-
model.indices.each { |field| indices[field] = Array(send(field)) }
|
1337
|
+
model.indices.each { |field| indices[field] = Array(send(field)).map(&:to_s) }
|
1338
1338
|
|
1339
1339
|
uniques = {}
|
1340
|
-
model.uniques.each { |field| uniques[field] = send(field) }
|
1340
|
+
model.uniques.each { |field| uniques[field] = send(field).to_s }
|
1341
1341
|
|
1342
1342
|
features = {
|
1343
1343
|
"name" => model.name
|
data/lib/ohm/lua/save.lua
CHANGED
@@ -57,7 +57,7 @@ end
|
|
57
57
|
local function index(model, indices)
|
58
58
|
for field, enum in pairs(indices) do
|
59
59
|
for _, val in ipairs(enum) do
|
60
|
-
local key = model.name .. ":indices:" .. field .. ":" ..
|
60
|
+
local key = model.name .. ":indices:" .. field .. ":" .. val
|
61
61
|
|
62
62
|
redis.call("SADD", model.key .. ":_indices", key)
|
63
63
|
redis.call("SADD", key, model.id)
|
@@ -78,7 +78,7 @@ end
|
|
78
78
|
local function unique(model, uniques)
|
79
79
|
for field, value in pairs(uniques) do
|
80
80
|
local key = model.name .. ":uniques:" .. field
|
81
|
-
local val =
|
81
|
+
local val = value
|
82
82
|
|
83
83
|
redis.call("HSET", model.key .. ":_uniques", key, val)
|
84
84
|
redis.call("HSET", key, val, model.id)
|
@@ -99,7 +99,7 @@ local function verify(model, uniques)
|
|
99
99
|
|
100
100
|
for field, value in pairs(uniques) do
|
101
101
|
local key = model.name .. ":uniques:" .. field
|
102
|
-
local id = redis.call("HGET", key,
|
102
|
+
local id = redis.call("HGET", key, value)
|
103
103
|
|
104
104
|
if id and id ~= tostring(model.id) then
|
105
105
|
duplicates[#duplicates + 1] = field
|
data/ohm.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "ohm"
|
3
|
-
s.version = "3.0.
|
3
|
+
s.version = "3.0.2"
|
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"]
|
data/test/indices.rb
CHANGED
@@ -124,4 +124,15 @@ scope do
|
|
124
124
|
|
125
125
|
assert_equal nil, Node.with(:available, true)
|
126
126
|
end
|
127
|
+
|
128
|
+
test "float to string" do
|
129
|
+
u1 = User.create(:email => "foo", :update => 3.0)
|
130
|
+
u2 = User.create(:email => "bar", :update => 3)
|
131
|
+
|
132
|
+
assert User.find(:update => 3.0).include?(u1)
|
133
|
+
assert User.find(:update => 3).include?(u2)
|
134
|
+
|
135
|
+
assert !User.find(:update => 3.0).include?(u2)
|
136
|
+
assert !User.find(:update => 3).include?(u1)
|
137
|
+
end
|
127
138
|
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.
|
4
|
+
version: 3.0.2
|
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-
|
13
|
+
date: 2016-04-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: redic
|