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

[5.5] Only add value to binding if it isn't an expression #22451

Merged
merged 1 commit into from
Dec 16, 2017

Conversation

mfn
Copy link
Contributor

@mfn mfn commented Dec 16, 2017

Fixes #22213

Before (wrong SQL being generated):

>>> DB::table('test')->whereDate('col_date', DB::Raw('NOW()'))->where('col_misc', 'test')->get();
Illuminate\Database\QueryException with message 'SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `test` where date(`col_date`) = NOW() and `col_misc` = NOW())'

After (correct SQL):

>>> DB::table('test')->whereDate('col_date', DB::Raw('NOW()'))->where('col_misc', 'test')->get();
Illuminate\Database\QueryException with message 'SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `test` where date(`col_date`) = NOW() and `col_misc` = test)'

The ->toSql() doesn't show the problem, thus the test checks the bindings.

Without the fix, the bindings would return the expression too, which it shouldn't.

@mfn
Copy link
Contributor Author

mfn commented Dec 16, 2017

@dattz I believe this fixes your reported issue #22213 , can you check?

@taylorotwell taylorotwell merged commit 6984b4e into laravel:5.5 Dec 16, 2017
@mfn mfn deleted the date-dont-bind-expression branch December 16, 2017 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants