-
Notifications
You must be signed in to change notification settings - Fork 34
sqlite function in insert break other values #87
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Apparently the following parsed statement is not good enough to pass:
insert into timestamps (fid, date) values(:fid, julianday('now'))"it does insert the date, but sadly ignore fid.
🤔 not sure how this would be solved 😭
function DB:insert(tbl_name, rows)
--- ...
clib.wrap_stmts(self.conn, function()
for _, v in ipairs(items) do
local s = stmt:parse(self.conn, P.insert(tbl_name, { values = v }))
--> P.insert(....) => "insert into timestamps (fid, date) values(:fid, julianday('now'))"
--> stmt:parse(..) => "insert into timestamps (fid, date) values(NULL, julianday('now'))"
s:bind(v)
s:step()
s:bind_clear()
table.insert(ret_vals, s:finalize())
end
end)
endOn the parser side, instead of binding to :date it uses the value in place.
local pvalues = function(defs, kv)
--- ....
local keys = {}
for k, v in u.opairs(defs) do
if type(v) == "string" and v:match "%a+%(.+%)" then
tinsert(keys, v)
else
tinsert(keys, ":" .. k)
end
end
return ("values(%s)"):format(tconcat(keys, ", "))
endReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working