-
Notifications
You must be signed in to change notification settings - Fork 232
Add expressionToString to getOtherClauses #451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fix error: Object of class Illuminate\Database\Query\Expression could not be converted to string
@mikebronner can you merge this, please?
Thanks!
@padre could you add a test that covers this specific use-case? I also made some small tweaks to the code.
@mikebronner Thank you very much for your quick response and your attention, but I don't think I have the necessary knowledge to add a test.
The exception occurs when I use ->has() in a belongsToMany relationship.
class Investigation extends Model
{
public function vigilances()
{
return $this->belongsToMany(Vigilance::class);
}
}
class Vigilance extends Model
{
public function investigations()
{
return $this->belongsToMany(Investigation::class);
}
}
$investigation
->vigilances()
->has('investigations', '=', 1)
->get();
This causes in the method "getOtherClauses(array $where)" in the statement
$column .= isset($where["column"]) ? $where["column"] : "";
the exception "Object of class IlluminateDatabaseQueryExpression could not be converted to string".
If i try to dump $where variable and got:
array:5 [
"type" => "Basic"
"column" => Illuminate\Database\Query\Expression {#3051 ▼
#value: "(select count(*) from `investigations` inner join `investigation_vigilance` on `investigations`.`id` = `investigation_vigilance`.`investigation_id` where `vigilances`.`id` = `investigation_vigilance`.`vigilance_id` and `investigations`.`deleted_at` is null) ◀"
}
"operator" => "="
"value" => Illuminate\Database\Query\Expression {#3053 ▼
#value: 1
}
"boolean" => "and"
Thank you very much for your dedication.
Uh oh!
There was an error while loading. Please reload this page.
Fix exception: Object of class Illuminate\Database\Query\Expression could not be converted to string
Related: #441
Eloquent query that caused the bug, for example:
If i try to dump $where variable and got: