forked from tarantool/tarantool
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
After this patch, the result type of arithmetic between two unsigned values will be INTEGER. Closes tarantool#7295 NO_DOC=bugfix
- Loading branch information
Showing
3 changed files
with
50 additions
and
4 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 @@ | ||
## bugfix/sql | ||
|
||
* The result type of arithmetic between two unsigned values is now | ||
INTEGER (gh-7295). |
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,43 @@ | ||
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_uint_int'}) | ||
g.server:start() | ||
g.server:exec(function() | ||
box.execute([[CREATE TABLE t(i UNSIGNED PRIMARY KEY, a UNSIGNED);]]) | ||
box.execute([[INSERT INTO t VALUES (1, 2);]]) | ||
end) | ||
end) | ||
|
||
g.after_all(function() | ||
g.server:exec(function() | ||
box.execute([[DROP TABLE t;]]) | ||
end) | ||
g.server:stop() | ||
end) | ||
|
||
g.test_uint_int_1 = function() | ||
g.server:exec(function() | ||
local t = require('luatest') | ||
local res = {{name = "COLUMN_1", type = "integer"}} | ||
t.assert_equals(box.execute([[SELECT i + a FROM t;]]).metadata, res) | ||
t.assert_equals(box.execute([[SELECT i - a FROM t;]]).metadata, res) | ||
t.assert_equals(box.execute([[SELECT i * a FROM t;]]).metadata, res) | ||
t.assert_equals(box.execute([[SELECT i / a FROM t;]]).metadata, res) | ||
t.assert_equals(box.execute([[SELECT i % a FROM t;]]).metadata, res) | ||
t.assert_equals(box.execute([[SELECT i & a FROM t;]]).metadata, res) | ||
t.assert_equals(box.execute([[SELECT i | a FROM t;]]).metadata, res) | ||
t.assert_equals(box.execute([[SELECT i >> a FROM t;]]).metadata, res) | ||
t.assert_equals(box.execute([[SELECT i << a FROM t;]]).metadata, res) | ||
end) | ||
end | ||
|
||
g.test_uint_int_2 = function() | ||
g.server:exec(function() | ||
local t = require('luatest') | ||
local sql = [[SELECT i - a FROM t ORDER BY 1 LIMIT 1;]] | ||
t.assert_equals(box.execute(sql).rows, {{-1}}) | ||
end) | ||
end |