@@ -128,6 +128,33 @@ public function where_null()
128128 $ this ->assertEquals ($ id3 , $ query ->get ()[1 ]->id );
129129 }
130130
131+ /** @test */
132+ public function where_null_raw ()
133+ {
134+ $ query = DB ::table ('test ' )->whereNull (DB ::raw ('(SELECT NULL) ' ))->orderBy ('id ' );
135+
136+ $ this ->assertEquals (
137+ 'select * from `test` where (SELECT NULL) is null order by `id` asc ' ,
138+ $ query ->toSql ()
139+ );
140+
141+ if (! $ this ->runHybridIntegrations ()) {
142+ return ;
143+ }
144+
145+ [$ id1 , $ id2 , $ id3 , $ id4 ] = $ this ->insertJsonData ([
146+ ['value1 ' => ['value2 ' => 'string ' ]],
147+ ['value1 ' => null ],
148+ [null ],
149+ ['value1 ' => ['value2 ' => 1 ]],
150+ ]);
151+
152+ $ this ->assertEquals ($ id1 , $ query ->get ()[0 ]->id );
153+ $ this ->assertEquals ($ id2 , $ query ->get ()[1 ]->id );
154+ $ this ->assertEquals ($ id3 , $ query ->get ()[2 ]->id );
155+ $ this ->assertEquals ($ id4 , $ query ->get ()[3 ]->id );
156+ }
157+
131158 /** @test */
132159 public function where_not_null ()
133160 {
@@ -153,4 +180,31 @@ public function where_not_null()
153180 $ this ->assertEquals ($ id1 , $ query ->get ()[0 ]->id );
154181 $ this ->assertEquals ($ id4 , $ query ->get ()[1 ]->id );
155182 }
183+
184+ /** @test */
185+ public function where_not_null_raw ()
186+ {
187+ $ query = DB ::table ('test ' )->whereNotNull (DB ::raw ('(SELECT 1) ' ))->orderBy ('id ' );
188+
189+ $ this ->assertEquals (
190+ 'select * from `test` where (SELECT 1) is not null order by `id` asc ' ,
191+ $ query ->toSql ()
192+ );
193+
194+ if (! $ this ->runHybridIntegrations ()) {
195+ return ;
196+ }
197+
198+ [$ id1 , $ id2 , $ id3 , $ id4 ] = $ this ->insertJsonData ([
199+ ['value1 ' => ['value2 ' => 'string ' ]],
200+ ['value1 ' => null ],
201+ [null ],
202+ ['value1 ' => ['value2 ' => 1 ]],
203+ ]);
204+
205+ $ this ->assertEquals ($ id1 , $ query ->get ()[0 ]->id );
206+ $ this ->assertEquals ($ id2 , $ query ->get ()[1 ]->id );
207+ $ this ->assertEquals ($ id3 , $ query ->get ()[2 ]->id );
208+ $ this ->assertEquals ($ id4 , $ query ->get ()[3 ]->id );
209+ }
156210}
0 commit comments