lib/ohm/lua/save.lua in ohm-3.0.1 vs lib/ohm/lua/save.lua in ohm-3.0.2
- old
+ new
@@ -55,11 +55,11 @@
end
local function index(model, indices)
for field, enum in pairs(indices) do
for _, val in ipairs(enum) do
- local key = model.name .. ":indices:" .. field .. ":" .. tostring(val)
+ local key = model.name .. ":indices:" .. field .. ":" .. val
redis.call("SADD", model.key .. ":_indices", key)
redis.call("SADD", key, model.id)
end
end
@@ -76,11 +76,11 @@
end
local function unique(model, uniques)
for field, value in pairs(uniques) do
local key = model.name .. ":uniques:" .. field
- local val = tostring(value)
+ local val = value
redis.call("HSET", model.key .. ":_uniques", key, val)
redis.call("HSET", key, val, model.id)
end
end
@@ -97,10 +97,10 @@
local function verify(model, uniques)
local duplicates = {}
for field, value in pairs(uniques) do
local key = model.name .. ":uniques:" .. field
- local id = redis.call("HGET", key, tostring(value))
+ local id = redis.call("HGET", key, value)
if id and id ~= tostring(model.id) then
duplicates[#duplicates + 1] = field
end
end