forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: change rules used to determine NULLIF() type
This patch introduces new rules to determine type of NULLIF() built-in function. Closes tarantool#6990 @TarantoolBot document Title: New rules to determine type of result of NULLIF The type of the result of NULLIF() function now matches the type of the first argument.
- Loading branch information
Showing
5 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## feature/sql | ||
|
||
* Now the type of result of NULLIF() is the same as the type of the first | ||
argument (gh-6989). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
local server = require('test.luatest_helpers.server') | ||
local t = require('luatest') | ||
local g = t.group() | ||
|
||
g.before_all(function() | ||
g.server = server:new({alias = 'test_assertion_in_modulo'}) | ||
g.server:start() | ||
end) | ||
|
||
g.after_all(function() | ||
g.server:stop() | ||
end) | ||
|
||
g.test_assertion_in_modulo = function() | ||
g.server:exec(function() | ||
local t = require('luatest') | ||
local sql = "SELECT nullif(1, '2');" | ||
local res = "integer" | ||
t.assert_equals(box.execute(sql).metadata[1].type, res) | ||
|
||
sql = "SELECT nullif('1', '1');" | ||
res = "string" | ||
t.assert_equals(box.execute(sql).metadata[1].type, res) | ||
|
||
sql = "SELECT nullif([1], '2');" | ||
res = "Failed to execute SQL statement: wrong arguments for function ".. | ||
"NULLIF()" | ||
local _, err = box.execute(sql) | ||
t.assert_equals(err.message, res) | ||
|
||
sql = "SELECT nullif(1, [2]);" | ||
res = "Type mismatch: can not convert array([2]) to scalar" | ||
_, err = box.execute(sql) | ||
t.assert_equals(err.message, res) | ||
end) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters