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 @@ -3209,6 +3209,10 @@ protected function objectToArray($object)
32093209 return $ object ;
32103210 }
32113211
3212+ if ($ object instanceof RawSql) {
3213+ throw new InvalidArgumentException ('RawSql " ' . $ object . '" cannot be used here. ' );
3214+ }
3215+
32123216 $ array = [];
32133217
32143218 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