@@ -670,6 +670,46 @@ public void testNestedTypeSimpleStatement() throws SQLException {
670670 }
671671 }
672672
673+ @ Test
674+ public void testTupleTypeSimpleStatement () throws SQLException {
675+ runQuery ("CREATE TABLE test_tuple (order Int8, "
676+ + "tuple Tuple(int8 Int8, int16 Int16, int32 Int32, int64 Int64, int128 Int128, int256 Int256)"
677+ + ") ENGINE = Memory" );
678+
679+ // Insert random (valid) values
680+ long seed = System .currentTimeMillis ();
681+ Random rand = new Random (seed );
682+ log .info ("Random seed was: {}" , seed );
683+
684+ int int8 = rand .nextInt (256 ) - 128 ;
685+ int int16 = rand .nextInt (65536 ) - 32768 ;
686+ int int32 = rand .nextInt ();
687+ long int64 = rand .nextLong ();
688+ BigInteger int128 = new BigInteger (127 , rand );
689+ BigInteger int256 = new BigInteger (255 , rand );
690+
691+ String sql = String .format ("INSERT INTO test_tuple VALUES ( 1, (%s, %s, %s, %s, %s, %s))" ,
692+ int8 , int16 , int32 , int64 , int128 , int256 );
693+ insertData (sql );
694+
695+ // Check the results
696+ try (Connection conn = getConnection ()) {
697+ try (Statement stmt = conn .createStatement ()) {
698+ try (ResultSet rs = stmt .executeQuery ("SELECT * FROM test_tuple ORDER BY order" )) {
699+ assertTrue (rs .next ());
700+ Object [] tuple = (Object []) rs .getObject (2 );
701+ assertEquals (String .valueOf (tuple [0 ]), String .valueOf (int8 ));
702+ assertEquals (String .valueOf (tuple [1 ]), String .valueOf (int16 ));
703+ assertEquals (String .valueOf (tuple [2 ]), String .valueOf (int32 ));
704+ assertEquals (String .valueOf (tuple [3 ]), String .valueOf (int64 ));
705+ assertEquals (String .valueOf (tuple [4 ]), String .valueOf (int128 ));
706+ assertEquals (String .valueOf (tuple [5 ]), String .valueOf (int256 ));
707+ assertFalse (rs .next ());
708+ }
709+ }
710+ }
711+ }
712+
673713
674714
675715 @ Test (enabled = false )//TODO: This type is experimental right now
0 commit comments