Skip to content

Commit d6ede31

Browse files
committed
test: fix compatibility with Tarantool master
New behavior: SELECT scan queries are only allowed if the SEQSCAN keyword is used correctly[1]. 1. https://www.tarantool.io/en/doc/latest/reference/reference_lua/compat/sql_seq_scan_default/ Related to tarantool/tarantool#8602
1 parent ab957c4 commit d6ede31

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
1515
### Fixed
1616

1717
- crud tests with Tarantool 3.0 (#293)
18+
- SQL tests with Tarantool 3.0 (#295)
1819

1920
## [1.11.0] - 2023-05-18
2021

settings/tarantool_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,14 @@ func TestSQLReverseUnorderedSelectsSetting(t *testing.T) {
481481
require.Equal(t, []interface{}{[]interface{}{"sql_reverse_unordered_selects", false}}, resp.Data)
482482

483483
// Select multiple records.
484-
resp, err = conn.Execute("SELECT * FROM data;", []interface{}{})
484+
query := "SELECT * FROM seqscan data;"
485+
if isSeqScanOld, err := test_helpers.IsTarantoolVersionLess(3, 0, 0); err != nil {
486+
t.Fatal("Could not check the Tarantool version")
487+
} else if isSeqScanOld {
488+
query = "SELECT * FROM data;"
489+
}
490+
491+
resp, err = conn.Execute(query, []interface{}{})
485492
require.Nil(t, err)
486493
require.NotNil(t, resp)
487494
require.EqualValues(t, []interface{}{"1"}, resp.Data[0])
@@ -500,7 +507,7 @@ func TestSQLReverseUnorderedSelectsSetting(t *testing.T) {
500507
require.Equal(t, []interface{}{[]interface{}{"sql_reverse_unordered_selects", true}}, resp.Data)
501508

502509
// Select multiple records.
503-
resp, err = conn.Execute("SELECT * FROM data;", []interface{}{})
510+
resp, err = conn.Execute(query, []interface{}{})
504511
require.Nil(t, err)
505512
require.NotNil(t, resp)
506513
require.EqualValues(t, []interface{}{"2"}, resp.Data[0])

tarantool_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,8 @@ const (
13301330
selectPosQuery = "SELECT id, name FROM SQL_SPACE WHERE id=? AND name=?;"
13311331
updateQuery = "UPDATE SQL_SPACE SET name=? WHERE id=?;"
13321332
enableFullMetaDataQuery = "SET SESSION \"sql_full_metadata\" = true;"
1333-
selectSpanDifQuery = "SELECT id||id, name, id FROM SQL_SPACE WHERE name=?;"
1333+
selectSpanDifQueryNew = "SELECT id||id, name, id FROM seqscan SQL_SPACE WHERE name=?;"
1334+
selectSpanDifQueryOld = "SELECT id||id, name, id FROM SQL_SPACE WHERE name=?;"
13341335
alterTableQuery = "ALTER TABLE SQL_SPACE RENAME TO SQL_SPACE2;"
13351336
insertIncrQuery = "INSERT INTO SQL_SPACE2 VALUES (?, ?);"
13361337
deleteQuery = "DELETE FROM SQL_SPACE2 WHERE name=?;"
@@ -1353,6 +1354,13 @@ func TestSQL(t *testing.T) {
13531354
Resp Response
13541355
}
13551356

1357+
selectSpanDifQuery := selectSpanDifQueryNew
1358+
if isSeqScanOld, err := test_helpers.IsTarantoolVersionLess(3, 0, 0); err != nil {
1359+
t.Fatal("Could not check the Tarantool version")
1360+
} else if isSeqScanOld {
1361+
selectSpanDifQuery = selectSpanDifQueryOld
1362+
}
1363+
13561364
testCases := []testCase{
13571365
{
13581366
createTableQuery,
@@ -1498,7 +1506,7 @@ func TestSQL(t *testing.T) {
14981506

14991507
for i, test := range testCases {
15001508
resp, err := conn.Execute(test.Query, test.Args)
1501-
assert.NoError(t, err, "Failed to Execute, Query number: %d", i)
1509+
assert.NoError(t, err, "Failed to Execute, query: %s", test.Query)
15021510
assert.NotNil(t, resp, "Response is nil after Execute\nQuery number: %d", i)
15031511
for j := range resp.Data {
15041512
assert.Equal(t, resp.Data[j], test.Resp.Data[j], "Response data is wrong")

0 commit comments

Comments
 (0)