@@ -492,6 +492,94 @@ public void testDecimalFields(TestContext context) {
492492 });
493493 }
494494
495+ protected abstract String createByteArray1TableColumn ();
496+ protected abstract String createByteArray2TableColumn ();
497+ protected abstract String createByteArray3TableColumn ();
498+ protected abstract String [] insertByteArray1Values ();
499+ protected abstract String [] insertByteArray2Values ();
500+ protected abstract String [] insertByteArray3Values ();
501+
502+ @ Test
503+ public void testByteA1Fields (TestContext context ) {
504+ Async async = context .async ();
505+ client .getConnection (arConn -> {
506+ ensureSuccess (context , arConn );
507+ conn = arConn .result ();
508+ conn .execute ("DROP TABLE IF EXISTS test_table" , arDrop -> {
509+ ensureSuccess (context , arDrop );
510+ conn .execute ("CREATE TABLE test_table (id INT, some_bit " + createByteArray1TableColumn () + ")" , arCreate -> {
511+ ensureSuccess (context , arCreate );
512+ String [] s = insertByteArray1Values ();
513+ conn .execute ("INSERT INTO test_table (id, some_bit) VALUES (1, " + s [0 ] + "),(2, " + s [1 ] + "),(3, " + s [2 ] + ")" , arInsert -> {
514+ ensureSuccess (context , arInsert );
515+ conn .query ("SELECT some_bit FROM test_table ORDER BY id" , arQuery -> {
516+ ensureSuccess (context , arQuery );
517+ ResultSet res = arQuery .result ();
518+ context .assertTrue (Arrays .equals (new byte []{0b1}, res .getRows ().get (0 ).getBinary ("some_bit" )));
519+ context .assertTrue (Arrays .equals (new byte []{0b0}, res .getResults ().get (1 ).getBinary (0 )));
520+ context .assertTrue (Arrays .equals (new byte []{0b1}, res .getRows ().get (2 ).getBinary ("some_bit" )));
521+ async .complete ();
522+ });
523+ });
524+ });
525+ });
526+ });
527+ }
528+
529+ @ Test
530+ public void testByteA2Fields (TestContext context ) {
531+ Async async = context .async ();
532+ client .getConnection (arConn -> {
533+ ensureSuccess (context , arConn );
534+ conn = arConn .result ();
535+ conn .execute ("DROP TABLE IF EXISTS test_table" , arDrop -> {
536+ ensureSuccess (context , arDrop );
537+ conn .execute ("CREATE TABLE test_table (id INT, some_bit " + createByteArray2TableColumn () + ")" , arCreate -> {
538+ ensureSuccess (context , arCreate );
539+ String [] s = insertByteArray2Values ();
540+ conn .execute ("INSERT INTO test_table (id, some_bit) VALUES (1, " + s [0 ] + "),(2, " + s [1 ] + "),(3, " + s [2 ] + ")" , arInsert -> {
541+ ensureSuccess (context , arInsert );
542+ conn .query ("SELECT some_bit FROM test_table ORDER BY id" , arQuery -> {
543+ ensureSuccess (context , arQuery );
544+ ResultSet res = arQuery .result ();
545+ context .assertTrue (Arrays .equals (new byte []{0b10}, res .getRows ().get (0 ).getBinary ("some_bit" )));
546+ context .assertTrue (Arrays .equals (new byte []{0b01}, res .getResults ().get (1 ).getBinary (0 )));
547+ context .assertTrue (Arrays .equals (new byte []{0b11}, res .getRows ().get (2 ).getBinary ("some_bit" )));
548+ async .complete ();
549+ });
550+ });
551+ });
552+ });
553+ });
554+ }
555+
556+ @ Test
557+ public void testByteA3Fields (TestContext context ) {
558+ Async async = context .async ();
559+ client .getConnection (arConn -> {
560+ ensureSuccess (context , arConn );
561+ conn = arConn .result ();
562+ conn .execute ("DROP TABLE IF EXISTS test_table" , arDrop -> {
563+ ensureSuccess (context , arDrop );
564+ conn .execute ("CREATE TABLE test_table (id INT, some_bit " + createByteArray3TableColumn () + ")" , arCreate -> {
565+ ensureSuccess (context , arCreate );
566+ String [] s = insertByteArray3Values ();
567+ conn .execute ("INSERT INTO test_table (id, some_bit) VALUES (1, " + s [0 ] + "),(2, " + s [1 ] + "),(3, " + s [2 ] + ")" , arInsert -> {
568+ ensureSuccess (context , arInsert );
569+ conn .query ("SELECT some_bit FROM test_table ORDER BY id" , arQuery -> {
570+ ensureSuccess (context , arQuery );
571+ ResultSet res = arQuery .result ();
572+ context .assertTrue (Arrays .equals (new byte []{0b1, 0b0}, res .getRows ().get (0 ).getBinary ("some_bit" )));
573+ context .assertTrue (Arrays .equals (new byte []{0b0, 0b1}, res .getResults ().get (1 ).getBinary (0 )));
574+ context .assertTrue (Arrays .equals (new byte []{0b1, 0b1}, res .getRows ().get (2 ).getBinary ("some_bit" )));
575+ async .complete ();
576+ });
577+ });
578+ });
579+ });
580+ });
581+ }
582+
495583 protected void setSqlModeIfPossible (Handler <Void > handler ) {
496584 handler .handle (null );
497585 }
0 commit comments