db icon indicating copy to clipboard operation
db copied to clipboard

Nested "orWhere" WhereClauses broken when using CRUD

Open defunctl opened this issue 1 year ago • 0 comments

Running something like this should reproduce it:

DB::table( 'posts' )
  ->where( 'post_author', 10 )
  ->where( static function( WhereQueryBuilder $builder ) {
	  $builder->where( 'post_status', 'published' )
	          ->orWhere( 'post_name', 'hello-world' );
  } )->update( [
		'post_except' => 'Testing 123', 
  ] );

There are two cases of WhereClauses that create strings, instead of a Where instance:

  1. one
  2. two

Then, when CRUD::getWhere() runs, it expects these to be Where instances, so the library throws notices here as it's not an object, but crashes in tests where notices throw exceptions (as it should, pointing out this bug).

defunctl avatar Nov 18 '24 20:11 defunctl