Don't choke on failed node name parsing
This commit is contained in:
parent
71d2e537dd
commit
4a810e9964
@ -11,7 +11,11 @@ end
|
|||||||
|
|
||||||
local function setup(db)
|
local function setup(db)
|
||||||
db:create_function("parse_node_name", 1, function(ctx, table_name)
|
db:create_function("parse_node_name", 1, function(ctx, table_name)
|
||||||
local obj = csexp.parse(table_name)
|
local ok, obj = pcall(csexp.parse, table_name)
|
||||||
|
if not ok then
|
||||||
|
ctx:result_null()
|
||||||
|
return
|
||||||
|
end
|
||||||
if type(obj) ~= "table" or obj[1] ~= "node" then
|
if type(obj) ~= "table" or obj[1] ~= "node" then
|
||||||
ctx:result_null()
|
ctx:result_null()
|
||||||
return
|
return
|
||||||
|
@ -44,4 +44,12 @@ describe("schema", function()
|
|||||||
expect.equal(expected, actual)
|
expect.equal(expected, actual)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe("parse_node_name", function()
|
||||||
|
it("returns NULL on non-sexp table names", function()
|
||||||
|
for val in db:urows("SELECT parse_node_name('not a sexp')") do
|
||||||
|
expect.not_exist(val)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
end)
|
end)
|
Loading…
Reference in New Issue
Block a user