diff --git a/lua/sqlite/helpers.lua b/lua/sqlite/helpers.lua index 0fa68d14..4be35b6c 100644 --- a/lua/sqlite/helpers.lua +++ b/lua/sqlite/helpers.lua @@ -74,7 +74,12 @@ M.run = function(func, o) if o.tbl_exists == nil then o.tbl_exists = o.db:exists(o.name) o.mtime = o.db.uri and (luv.fs_stat(o.db.uri) or { mtime = {} }).mtime.sec or nil - o.has_content = o.tbl_exists and o.db:eval(fmt("select count(*) from %s", o.name))[1]["count(*)"] ~= 0 or 0 + rawset( + o, + "has_content", + o.tbl_exists and o.db:eval(fmt("select count(*) from %s", o.name))[1]["count(*)"] ~= 0 or 0 + ) + -- o.has_content = M.check_for_auto_alter(o, valid_schema) end diff --git a/lua/sqlite/parser.lua b/lua/sqlite/parser.lua index 79675084..4119bb9d 100644 --- a/lua/sqlite/parser.lua +++ b/lua/sqlite/parser.lua @@ -120,7 +120,7 @@ local pvalues = function(defs, kv) local keys = {} for k, v in u.opairs(defs) do - if type(v) == "string" and v:match "%a+%(.+%)" then + if type(v) == "string" and v:match "^[%S]+%(.*%)$" then tinsert(keys, v) else tinsert(keys, ":" .. k) @@ -341,7 +341,7 @@ local opts_to_str = function(tbl) end end, default = function(v) - v = (type(v) == "string" and v:match "^%a+%(.+%)$") and "(" .. tostring(v) .. ")" or v + v = (type(v) == "string" and v:match "^[%S]+%(.*%)$") and "(" .. tostring(v) .. ")" or v local str = "default " if tbl["required"] then return "on conflict replace " .. str .. v diff --git a/lua/sqlite/stmt.lua b/lua/sqlite/stmt.lua index e95438eb..6277a16a 100644 --- a/lua/sqlite/stmt.lua +++ b/lua/sqlite/stmt.lua @@ -302,7 +302,7 @@ function sqlstmt:bind(...) for k, v in pairs(names) do local index = parameter_index_cache[k] or table.remove(anon_indices, 1) - if ((type(v) == "string" and v:match "%a+%(.+%)") and flags.ok or self:bind(index, v)) ~= flags.ok then + if ((type(v) == "string" and v:match "^[%S]+%(.*%)$") and flags.ok or self:bind(index, v)) ~= flags.ok then error("sqlite.lua error at stmt:bind(), failed to bind a given value '%s'. Please report issue."):format(v) end end