6
6
import static org .junit .jupiter .api .Assertions .assertThrows ;
7
7
import static org .junit .jupiter .api .Assertions .assertTrue ;
8
8
import static org .tarantool .TestAssumptions .assumeMinimalServerVersion ;
9
+ import static org .tarantool .TestAssumptions .assumeServerVersionLessThan ;
9
10
10
11
import org .tarantool .ServerVersion ;
11
12
import org .tarantool .TarantoolTestHelper ;
12
- import org .tarantool .jdbc .type .JdbcType ;
13
- import org .tarantool .jdbc .type .TarantoolSqlType ;
14
13
15
14
import org .junit .jupiter .api .AfterAll ;
16
15
import org .junit .jupiter .api .AfterEach ;
@@ -201,9 +200,11 @@ public void testCaseSensitiveColumns() throws SQLException {
201
200
@ Test
202
201
@ DisplayName ("returned case insensitive columns" )
203
202
public void testCaseInsensitiveColumns () throws SQLException {
204
- testHelper .executeSql (
205
- "CREATE TABLE test(id INT PRIMARY KEY, num_val DOUBLE)"
206
- );
203
+ if (ServerVersion .V_2_2 .isGreaterThan (testHelper .getInstanceVersion ())) {
204
+ testHelper .executeSql ("CREATE TABLE test(id INT PRIMARY KEY, num_val DOUBLE)" );
205
+ } else {
206
+ testHelper .executeSql ("CREATE TABLE test(id INT PRIMARY KEY, num_val NUMBER)" );
207
+ }
207
208
try (
208
209
Statement statement = connection .createStatement ();
209
210
ResultSet resultSet = statement .executeQuery ("SELECT * FROM test" )
@@ -218,9 +219,15 @@ public void testCaseInsensitiveColumns() throws SQLException {
218
219
@ Test
219
220
@ DisplayName ("returned searchable columns" )
220
221
public void testSearchableColumns () throws SQLException {
221
- testHelper .executeSql (
222
- "CREATE TABLE test(id INT PRIMARY KEY, num_val DOUBLE, text_val TEXT, bin_val SCALAR)"
223
- );
222
+ if (ServerVersion .V_2_2 .isGreaterThan (testHelper .getInstanceVersion ())) {
223
+ testHelper .executeSql (
224
+ "CREATE TABLE test(id INT PRIMARY KEY, num_val DOUBLE, text_val TEXT, bin_val SCALAR)"
225
+ );
226
+ } else {
227
+ testHelper .executeSql (
228
+ "CREATE TABLE test(id INT PRIMARY KEY, num_val NUMBER, text_val TEXT, bin_val SCALAR)"
229
+ );
230
+ }
224
231
try (
225
232
Statement statement = connection .createStatement ();
226
233
ResultSet resultSet = statement .executeQuery ("SELECT * FROM test" )
@@ -237,9 +244,15 @@ public void testSearchableColumns() throws SQLException {
237
244
@ Test
238
245
@ DisplayName ("returned no monetary columns" )
239
246
public void testCurrencyColumns () throws SQLException {
240
- testHelper .executeSql (
241
- "CREATE TABLE test(id INT PRIMARY KEY, num_val DOUBLE, text_val TEXT, bin_val SCALAR)"
242
- );
247
+ if (ServerVersion .V_2_2 .isGreaterThan (testHelper .getInstanceVersion ())) {
248
+ testHelper .executeSql (
249
+ "CREATE TABLE test(id INT PRIMARY KEY, num_val DOUBLE, text_val TEXT, bin_val SCALAR)"
250
+ );
251
+ } else {
252
+ testHelper .executeSql (
253
+ "CREATE TABLE test(id INT PRIMARY KEY, num_val NUMBER, text_val TEXT, bin_val SCALAR)"
254
+ );
255
+ }
243
256
try (
244
257
Statement statement = connection .createStatement ();
245
258
ResultSet resultSet = statement .executeQuery ("SELECT * FROM test" )
@@ -254,8 +267,9 @@ public void testCurrencyColumns() throws SQLException {
254
267
}
255
268
256
269
@ Test
257
- @ DisplayName ("returned signed columns" )
258
- public void testSignedColumns () throws SQLException {
270
+ @ DisplayName ("returned signed decimal columns" )
271
+ public void testSignedDecimalColumns () throws SQLException {
272
+ assumeServerVersionLessThan (testHelper .getInstanceVersion (), ServerVersion .V_2_2 );
259
273
testHelper .executeSql (
260
274
"CREATE TABLE test(id INT PRIMARY KEY, double_val DOUBLE, real_val REAL, float_val FLOAT)"
261
275
);
@@ -272,6 +286,23 @@ public void testSignedColumns() throws SQLException {
272
286
}
273
287
}
274
288
289
+ @ Test
290
+ @ DisplayName ("returned signed number column" )
291
+ public void testSignedNumberColumn () throws SQLException {
292
+ assumeMinimalServerVersion (testHelper .getInstanceVersion (), ServerVersion .V_2_2_1 );
293
+ testHelper .executeSql (
294
+ "CREATE TABLE test(id INT PRIMARY KEY, num_val NUMBER)"
295
+ );
296
+ try (
297
+ Statement statement = connection .createStatement ();
298
+ ResultSet resultSet = statement .executeQuery ("SELECT * FROM test" )
299
+ ) {
300
+ ResultSetMetaData rsMeta = resultSet .getMetaData ();
301
+ assertTrue (rsMeta .isSigned (1 ));
302
+ assertTrue (rsMeta .isSigned (2 ));
303
+ }
304
+ }
305
+
275
306
@ Test
276
307
@ DisplayName ("returned not signed columns" )
277
308
public void testNotSignedColumns () throws SQLException {
@@ -292,8 +323,9 @@ public void testNotSignedColumns() throws SQLException {
292
323
}
293
324
294
325
@ Test
295
- @ DisplayName ("returned numeric column types" )
296
- public void testColumnsNumericTypes () throws SQLException {
326
+ @ DisplayName ("returned number type aliases" )
327
+ public void testColumnsNumberTypeAliases () throws SQLException {
328
+ assumeServerVersionLessThan (testHelper .getInstanceVersion (), ServerVersion .V_2_2 );
297
329
testHelper .executeSql (
298
330
"CREATE TABLE test(id INT PRIMARY KEY, f_val FLOAT, d_val DOUBLE, r_val REAL)"
299
331
);
@@ -303,26 +335,45 @@ public void testColumnsNumericTypes() throws SQLException {
303
335
) {
304
336
ResultSetMetaData rsMeta = resultSet .getMetaData ();
305
337
306
- assertEquals (Types .INTEGER , rsMeta .getColumnType (1 ));
338
+ assertEquals (Types .BIGINT , rsMeta .getColumnType (1 ));
307
339
assertEquals ("integer" , rsMeta .getColumnTypeName (1 ));
308
- assertEquals ("java.lang.Integer " , rsMeta .getColumnClassName (1 ));
340
+ assertEquals ("java.lang.Long " , rsMeta .getColumnClassName (1 ));
309
341
310
342
// we cannot distinguish numeric types because Tarantool
311
343
// receives double noSQL type for all the numeric SQL types
312
344
assertEquals (Types .DOUBLE , rsMeta .getColumnType (2 ));
313
- assertEquals ("double " , rsMeta .getColumnTypeName (2 ));
345
+ assertEquals ("number " , rsMeta .getColumnTypeName (2 ));
314
346
assertEquals ("java.lang.Double" , rsMeta .getColumnClassName (2 ));
315
347
316
348
assertEquals (Types .DOUBLE , rsMeta .getColumnType (3 ));
317
- assertEquals ("double " , rsMeta .getColumnTypeName (3 ));
349
+ assertEquals ("number " , rsMeta .getColumnTypeName (3 ));
318
350
assertEquals ("java.lang.Double" , rsMeta .getColumnClassName (3 ));
319
351
320
352
assertEquals (Types .DOUBLE , rsMeta .getColumnType (4 ));
321
- assertEquals ("double " , rsMeta .getColumnTypeName (4 ));
353
+ assertEquals ("number " , rsMeta .getColumnTypeName (4 ));
322
354
assertEquals ("java.lang.Double" , rsMeta .getColumnClassName (4 ));
323
355
}
324
356
}
325
357
358
+ @ Test
359
+ @ DisplayName ("returned number column type" )
360
+ public void testColumnsNumericTypes () throws SQLException {
361
+ assumeMinimalServerVersion (testHelper .getInstanceVersion (), ServerVersion .V_2_2_1 );
362
+ testHelper .executeSql (
363
+ "CREATE TABLE test(id INT PRIMARY KEY, num_val NUMBER)"
364
+ );
365
+ try (
366
+ Statement statement = connection .createStatement ();
367
+ ResultSet resultSet = statement .executeQuery ("SELECT * FROM test" )
368
+ ) {
369
+ ResultSetMetaData rsMeta = resultSet .getMetaData ();
370
+
371
+ assertEquals (Types .DOUBLE , rsMeta .getColumnType (2 ));
372
+ assertEquals ("number" , rsMeta .getColumnTypeName (2 ));
373
+ assertEquals ("java.lang.Double" , rsMeta .getColumnClassName (2 ));
374
+ }
375
+ }
376
+
326
377
@ Test
327
378
@ DisplayName ("returned textual column types" )
328
379
public void testColumnsTextualTypes () throws SQLException {
@@ -335,17 +386,17 @@ public void testColumnsTextualTypes() throws SQLException {
335
386
) {
336
387
ResultSetMetaData rsMeta = resultSet .getMetaData ();
337
388
338
- assertEquals (Types .INTEGER , rsMeta .getColumnType (1 ));
389
+ assertEquals (Types .BIGINT , rsMeta .getColumnType (1 ));
339
390
assertEquals ("integer" , rsMeta .getColumnTypeName (1 ));
340
- assertEquals ("java.lang.Integer " , rsMeta .getColumnClassName (1 ));
391
+ assertEquals ("java.lang.Long " , rsMeta .getColumnClassName (1 ));
341
392
342
393
assertEquals (Types .VARCHAR , rsMeta .getColumnType (2 ));
343
- assertEquals ("varchar " , rsMeta .getColumnTypeName (2 ));
394
+ assertEquals ("string " , rsMeta .getColumnTypeName (2 ));
344
395
assertEquals ("java.lang.String" , rsMeta .getColumnClassName (2 ));
345
396
346
397
// TEXT and VARCHAR are not distinguishable
347
398
assertEquals (Types .VARCHAR , rsMeta .getColumnType (3 ));
348
- assertEquals ("varchar " , rsMeta .getColumnTypeName (3 ));
399
+ assertEquals ("string " , rsMeta .getColumnTypeName (3 ));
349
400
assertEquals ("java.lang.String" , rsMeta .getColumnClassName (3 ));
350
401
351
402
assertEquals (Types .BINARY , rsMeta .getColumnType (4 ));
0 commit comments