Skip to content
Snippets Groups Projects
Commit d228151e authored by Arseniy Volynets's avatar Arseniy Volynets
Browse files

fix: rewrite tests to pass, when exists sq returns > 1 row

parent 523ba256
No related branches found
No related tags found
1 merge request!1414sbroad import
...@@ -452,14 +452,19 @@ g.test_exists_subquery_with_several_rows = function () ...@@ -452,14 +452,19 @@ g.test_exists_subquery_with_several_rows = function ()
-- Exists condition should return true on each row from testing_space -- Exists condition should return true on each row from testing_space
-- as soon as it's subquery always returns two rows. -- as soon as it's subquery always returns two rows.
local _, err = api:call("sbroad.execute", { [[ local r, err = api:call("sbroad.execute", { [[
SELECT * FROM "testing_space" WHERE EXISTS (SELECT 0 FROM "t" WHERE "t"."id" = 1 or "t"."a" = (?)) SELECT * FROM "testing_space" WHERE EXISTS (SELECT 0 FROM "t" WHERE "t"."id" = 1 or "t"."a" = (?))
]], {require('decimal').new(6.66)} }) ]], {require('decimal').new(6.66)} })
t.assert_str_contains( t.assert_equals(err, nil)
tostring(err), t.assert_equals(r, {
"Failed to execute SQL statement: Expression subquery returned more than 1 row" metadata = {
) {name = "id", type = "integer"},
{name = "name", type = "string"},
{name = "product_units", type = "integer"},
},
rows = { {1, "123", 1} },
})
end end
g.test_not_exists_subquery_with_several_rows = function() g.test_not_exists_subquery_with_several_rows = function()
...@@ -467,15 +472,20 @@ g.test_not_exists_subquery_with_several_rows = function() ...@@ -467,15 +472,20 @@ g.test_not_exists_subquery_with_several_rows = function()
-- NotExists condition should return false on each row from testing_space -- NotExists condition should return false on each row from testing_space
-- as soon as it's subquery always returns two rows. -- as soon as it's subquery always returns two rows.
local _, err = api:call("sbroad.execute", { [[ local r, err = api:call("sbroad.execute", { [[
SELECT * FROM "testing_space" SELECT * FROM "testing_space"
WHERE NOT EXISTS (SELECT 0 FROM "t" WHERE "t"."id" = 1 or "t"."a" = (?)) WHERE NOT EXISTS (SELECT 0 FROM "t" WHERE "t"."id" = 1 or "t"."a" = (?))
]], {require('decimal').new(6.66)} }) ]], {require('decimal').new(6.66)} })
t.assert_str_contains( t.assert_equals(err, nil)
tostring(err), t.assert_equals(r, {
"Failed to execute SQL statement: Expression subquery returned more than 1 row" metadata = {
) {name = "id", type = "integer"},
{name = "name", type = "string"},
{name = "product_units", type = "integer"},
},
rows = {},
})
end end
g.test_exists_nested = function() g.test_exists_nested = function()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment