Skip to content

Commit 7d12be9

Browse files
committed
test: fix SQL and case sensitive cases
The feature will be introduced in Tarantool 3.0 [1]. 1. tarantool/tarantool#9249 (cherry picked from a422262)
1 parent 461ad48 commit 7d12be9

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
1414

1515
### Fixed
1616

17+
- Tests with case sensitive SQL (#341)
18+
1719
## [1.12.1] - 2023-08-03
1820

1921
The patch release with fixes from the master branch.

settings/tarantool_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func TestSQLDefaultEngineSetting(t *testing.T) {
116116
require.Equal(t, []interface{}{[]interface{}{"sql_default_engine", "vinyl"}}, resp.Data)
117117

118118
// Create a space with "CREATE TABLE".
119-
resp, err = conn.Execute("CREATE TABLE t1_vinyl(a INT PRIMARY KEY, b INT, c INT);", []interface{}{})
119+
resp, err = conn.Execute("CREATE TABLE T1_VINYL(a INT PRIMARY KEY, b INT, c INT);", []interface{}{})
120120
require.Nil(t, err)
121121
require.NotNil(t, resp)
122122
require.Equal(t, uint64(1), resp.SQLInfo.AffectedCount)
@@ -140,7 +140,7 @@ func TestSQLDefaultEngineSetting(t *testing.T) {
140140
require.Equal(t, []interface{}{[]interface{}{"sql_default_engine", "memtx"}}, resp.Data)
141141

142142
// Create a space with "CREATE TABLE".
143-
resp, err = conn.Execute("CREATE TABLE t2_memtx(a INT PRIMARY KEY, b INT, c INT);", []interface{}{})
143+
resp, err = conn.Execute("CREATE TABLE T2_MEMTX(a INT PRIMARY KEY, b INT, c INT);", []interface{}{})
144144
require.Nil(t, err)
145145
require.NotNil(t, resp)
146146
require.Equal(t, uint64(1), resp.SQLInfo.AffectedCount)
@@ -233,13 +233,13 @@ func TestSQLFullColumnNamesSetting(t *testing.T) {
233233
defer conn.Close()
234234

235235
// Create a space.
236-
resp, err = conn.Execute("CREATE TABLE fkname(id INT PRIMARY KEY, x INT);", []interface{}{})
236+
resp, err = conn.Execute("CREATE TABLE FKNAME(ID INT PRIMARY KEY, X INT);", []interface{}{})
237237
require.Nil(t, err)
238238
require.NotNil(t, resp)
239239
require.Equal(t, uint64(1), resp.SQLInfo.AffectedCount)
240240

241241
// Fill it with some data.
242-
resp, err = conn.Execute("INSERT INTO fkname VALUES (1, 1);", []interface{}{})
242+
resp, err = conn.Execute("INSERT INTO FKNAME VALUES (1, 1);", []interface{}{})
243243
require.Nil(t, err)
244244
require.NotNil(t, resp)
245245
require.Equal(t, uint64(1), resp.SQLInfo.AffectedCount)
@@ -257,7 +257,7 @@ func TestSQLFullColumnNamesSetting(t *testing.T) {
257257
require.Equal(t, []interface{}{[]interface{}{"sql_full_column_names", false}}, resp.Data)
258258

259259
// Get a data with short column names in metadata.
260-
resp, err = conn.Execute("SELECT x FROM fkname WHERE id = 1;", []interface{}{})
260+
resp, err = conn.Execute("SELECT X FROM FKNAME WHERE ID = 1;", []interface{}{})
261261
require.Nil(t, err)
262262
require.NotNil(t, resp)
263263
require.Equal(t, "X", resp.MetaData[0].FieldName)
@@ -275,7 +275,7 @@ func TestSQLFullColumnNamesSetting(t *testing.T) {
275275
require.Equal(t, []interface{}{[]interface{}{"sql_full_column_names", true}}, resp.Data)
276276

277277
// Get a data with full column names in metadata.
278-
resp, err = conn.Execute("SELECT x FROM fkname WHERE id = 1;", []interface{}{})
278+
resp, err = conn.Execute("SELECT X FROM FKNAME WHERE ID = 1;", []interface{}{})
279279
require.Nil(t, err)
280280
require.NotNil(t, resp)
281281
require.Equal(t, "FKNAME.X", resp.MetaData[0].FieldName)

tarantool_test.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,17 +1324,18 @@ func TestClientSessionPush(t *testing.T) {
13241324
}
13251325

13261326
const (
1327-
createTableQuery = "CREATE TABLE SQL_SPACE (id STRING PRIMARY KEY, name STRING COLLATE \"unicode\" DEFAULT NULL);"
1327+
createTableQuery = "CREATE TABLE SQL_SPACE (ID STRING PRIMARY KEY, NAME " +
1328+
"STRING COLLATE \"unicode\" DEFAULT NULL);"
13281329
insertQuery = "INSERT INTO SQL_SPACE VALUES (?, ?);"
1329-
selectNamedQuery = "SELECT id, name FROM SQL_SPACE WHERE id=:id AND name=:name;"
1330-
selectPosQuery = "SELECT id, name FROM SQL_SPACE WHERE id=? AND name=?;"
1331-
updateQuery = "UPDATE SQL_SPACE SET name=? WHERE id=?;"
1330+
selectNamedQuery = "SELECT ID, NAME FROM SQL_SPACE WHERE ID=:ID AND NAME=:NAME;"
1331+
selectPosQuery = "SELECT ID, NAME FROM SQL_SPACE WHERE ID=? AND NAME=?;"
1332+
updateQuery = "UPDATE SQL_SPACE SET NAME=? WHERE ID=?;"
13321333
enableFullMetaDataQuery = "SET SESSION \"sql_full_metadata\" = true;"
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=?;"
1334+
selectSpanDifQueryNew = "SELECT ID||ID, NAME, ID FROM seqscan SQL_SPACE WHERE NAME=?;"
1335+
selectSpanDifQueryOld = "SELECT ID||ID, NAME, ID FROM SQL_SPACE WHERE NAME=?;"
13351336
alterTableQuery = "ALTER TABLE SQL_SPACE RENAME TO SQL_SPACE2;"
13361337
insertIncrQuery = "INSERT INTO SQL_SPACE2 VALUES (?, ?);"
1337-
deleteQuery = "DELETE FROM SQL_SPACE2 WHERE name=?;"
1338+
deleteQuery = "DELETE FROM SQL_SPACE2 WHERE NAME=?;"
13381339
dropQuery = "DROP TABLE SQL_SPACE2;"
13391340
dropQuery2 = "DROP TABLE SQL_SPACE;"
13401341
disableFullMetaDataQuery = "SET SESSION \"sql_full_metadata\" = false;"
@@ -1383,8 +1384,8 @@ func TestSQL(t *testing.T) {
13831384
{
13841385
selectNamedQuery,
13851386
map[string]interface{}{
1386-
"id": "1",
1387-
"name": "test",
1387+
"ID": "1",
1388+
"NAME": "test",
13881389
},
13891390
Response{
13901391
SQLInfo: SQLInfo{AffectedCount: 0},
@@ -1434,22 +1435,22 @@ func TestSQL(t *testing.T) {
14341435
FieldName: "COLUMN_1",
14351436
FieldIsNullable: false,
14361437
FieldIsAutoincrement: false,
1437-
FieldSpan: "id||id",
1438+
FieldSpan: "ID||ID",
14381439
},
14391440
{
14401441
FieldType: "string",
14411442
FieldName: "NAME",
14421443
FieldIsNullable: true,
14431444
FieldIsAutoincrement: false,
1444-
FieldSpan: "name",
1445+
FieldSpan: "NAME",
14451446
FieldCollation: "unicode",
14461447
},
14471448
{
14481449
FieldType: "string",
14491450
FieldName: "ID",
14501451
FieldIsNullable: false,
14511452
FieldIsAutoincrement: false,
1452-
FieldSpan: "id",
1453+
FieldSpan: "ID",
14531454
FieldCollation: "",
14541455
},
14551456
}},

0 commit comments

Comments
 (0)