Skip to content
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

DB where Callback Bug #2831

Closed
lukaskleinschmidt opened this issue Sep 17, 2020 · 1 comment
Closed

DB where Callback Bug #2831

lukaskleinschmidt opened this issue Sep 17, 2020 · 1 comment
Assignees
Labels
type: bug 🐛 Is a bug; fixes a bug
Milestone

Comments

@lukaskleinschmidt
Copy link
Contributor

lukaskleinschmidt commented Sep 17, 2020

Describe the bug
Using a callback in the where clause takes on everything defined in the query.

$query->where('id', 1);
$query->where(fn ($q) => $q->where('status', 0));

Will produce something like this:

WHERE id = :value_1
AND (
    id = :value_1
    AND status = :value_2
)

The problem is that the binding is cloned as well and PDO allows a binding to be used only once.
Following error will be thrown SQLSTATE[HY093]: Invalid parameter number: parameter was not defined.

The reason for that is probably the clone here. Not sure if this should simply be a new query instance or if there is actually some stuff that needs be cloned.

Kirby Version
3.3.5

@bastianallgeier bastianallgeier added the type: bug 🐛 Is a bug; fixes a bug label Sep 21, 2020
afbora added a commit that referenced this issue Apr 6, 2022
afbora added a commit that referenced this issue Apr 8, 2022
afbora added a commit that referenced this issue Apr 8, 2022
@lukasbestle
Copy link
Member

@lukasbestle lukasbestle added this to the 3.6.5 milestone Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Is a bug; fixes a bug
Projects
None yet
Development

No branches or pull requests

3 participants