File tree Expand file tree Collapse file tree
tests/system/Database/Builder Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3215,6 +3215,10 @@ protected function objectToArray($object)
32153215 return $ object ;
32163216 }
32173217
3218+ if ($ object instanceof RawSql) {
3219+ throw new InvalidArgumentException ('RawSql " ' . $ object . '" cannot be used here. ' );
3220+ }
3221+
32183222 $ array = [];
32193223
32203224 foreach (get_object_vars ($ object ) as $ key => $ val ) {
Original file line number Diff line number Diff line change 1616use CodeIgniter \Database \RawSql ;
1717use CodeIgniter \Test \CIUnitTestCase ;
1818use CodeIgniter \Test \Mock \MockConnection ;
19+ use InvalidArgumentException ;
1920
2021/**
2122 * @internal
@@ -279,4 +280,22 @@ public function testInsertBatchThrowsExceptionOnEmptyData()
279280 $ this ->expectExceptionMessage ('insertBatch() has no data. ' );
280281 $ builder ->insertBatch ([]);
281282 }
283+
284+ public function testSetIncorrectRawSqlUsage ()
285+ {
286+ $ this ->expectException (InvalidArgumentException::class);
287+ $ this ->expectExceptionMessage (
288+ 'RawSql "expires = DATE_ADD(NOW(), INTERVAL 2 HOUR)" cannot be used here. '
289+ );
290+
291+ $ builder = $ this ->db ->table ('auth_bearer ' );
292+
293+ $ builder ->testMode ()
294+ ->set ([
295+ 'jti ' => 'jti ' ,
296+ 'proctorID ' => '12 ' ,
297+ ])
298+ ->set (new RawSql ('expires = DATE_ADD(NOW(), INTERVAL 2 HOUR) ' ))
299+ ->insert ();
300+ }
282301}
You can’t perform that action at this time.
0 commit comments