@@ -58,21 +58,53 @@ public function testSearchInArray(): void
5858 $ qb = $ conn ->table ($ tableName );
5959 $ qb ->insert ($ insertValues );
6060
61- $ qb = $ conn ->table ($ tableName );
62- $ result = $ qb -> whereInArray ( ' int64Array ' , 0 )-> get ( );
63- $ this ->assertCount (1 , $ result );
61+ $ qb = $ conn ->table ($ tableName )-> whereInArray ( ' int64Array ' , 0 ) ;
62+ $ this -> assertSame ( " select * from ` { $ tableName } ` where ? in unnest(` int64Array`) " , $ qb -> toSql () );
63+ $ this ->assertCount (1 , $ qb -> get () );
6464
65- $ qb = $ conn ->table ($ tableName );
66- $ result = $ qb -> whereInArray ( ' int64Array ' , 1 )-> get ( );
67- $ this ->assertCount (2 , $ result );
65+ $ qb = $ conn ->table ($ tableName )-> whereInArray ( ' int64Array ' , 1 ) ;
66+ $ this -> assertSame ( " select * from ` { $ tableName } ` where ? in unnest(` int64Array`) " , $ qb -> toSql () );
67+ $ this ->assertCount (2 , $ qb -> get () );
6868
69- $ qb = $ conn ->table ($ tableName );
70- $ result = $ qb -> whereInArray ( ' int64Array ' , 2 )-> get ( );
71- $ this ->assertCount (3 , $ result );
69+ $ qb = $ conn ->table ($ tableName )-> whereInArray ( ' int64Array ' , 2 ) ;
70+ $ this -> assertSame ( " select * from ` { $ tableName } ` where ? in unnest(` int64Array`) " , $ qb -> toSql () );
71+ $ this ->assertCount (3 , $ qb -> get () );
7272
73+ $ qb = $ conn ->table ($ tableName )->whereInArray ('int64Array ' , 300 );
74+ $ this ->assertSame ("select * from ` {$ tableName }` where ? in unnest(`int64Array`) " , $ qb ->toSql ());
75+ $ this ->assertCount (0 , $ qb ->get ());
76+ }
77+
78+ public function testSearchNotInArray (): void
79+ {
80+ $ conn = $ this ->getDefaultConnection ();
81+ $ tableName = self ::TABLE_NAME_ARRAY_TEST ;
82+
83+ $ testDataCount = 10 ;
84+ $ insertValues = [];
85+ for ($ i = 0 ; $ i < $ testDataCount ; $ i ++) {
86+ $ row = $ this ->generateArrayTestRow ();
87+ $ row ['int64Array ' ] = [$ i , $ i + 1 , $ i + 2 ];
88+ $ insertValues [] = $ row ;
89+ }
7390 $ qb = $ conn ->table ($ tableName );
74- $ result = $ qb ->whereInArray ('int64Array ' , 300 )->get ();
75- $ this ->assertCount (0 , $ result );
91+ $ qb ->insert ($ insertValues );
92+
93+ $ qb = $ conn ->table ($ tableName )->whereNotInArray ('int64Array ' , 0 );
94+ $ this ->assertSame ("select * from ` {$ tableName }` where ? not in unnest(`int64Array`) " , $ qb ->toSql ());
95+ $ this ->assertCount (9 , $ qb ->get ());
96+
97+ $ qb = $ conn ->table ($ tableName )->whereNotInArray ('int64Array ' , 1 );
98+ $ this ->assertSame ("select * from ` {$ tableName }` where ? not in unnest(`int64Array`) " , $ qb ->toSql ());
99+ $ this ->assertCount (8 , $ qb ->get ());
100+
101+ $ qb = $ conn ->table ($ tableName )->whereNotInArray ('int64Array ' , 2 );
102+ $ this ->assertSame ("select * from ` {$ tableName }` where ? not in unnest(`int64Array`) " , $ qb ->toSql ());
103+ $ this ->assertCount (7 , $ qb ->get ());
104+
105+ $ qb = $ conn ->table ($ tableName )->whereNotInArray ('int64Array ' , 300 );
106+ $ this ->assertSame ("select * from ` {$ tableName }` where ? not in unnest(`int64Array`) " , $ qb ->toSql ());
107+ $ this ->assertCount (10 , $ qb ->get ());
76108 }
77109
78110 public function testUpdateArray (): void
0 commit comments