-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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.6] whereYear criteria type issue #24058
Comments
I'm not sure this is considered a bug, the documentation uses quotes:
But I agree that it would be nice to have, since integers work with MySQL. |
It may be easier to fix if you can provide a unit test that currently fails. |
Here it is. The following test case fails on the last assertion.
And the model + test
Test output:
|
One more precision: The test is passing when executed on the Homestead MySQL database. It is failing when executed on the test SQLite :in_memory: database. Query generated on SQLite:
Query generated on MySQL:
So I guess that query is handled differently at the DB driver level. There may be a need to make the query more coherent by:
There may be a need to check behaviour for whereMonth and whereDay which probably is the same. |
We could use this in
|
Description:
Since #16737 is closed, I am opening this issue. I ran into the same issue when writing a query scope and unit testing it
If it helps to reproduce, I am using Homestead to run my unit tests. Tests are executed remotely on the VM using PHPStorm. I use a Windows OS to develop.
Steps To Reproduce:
This wont work since the year is an integer.
Order::whereYear('created_at', Carbon::now()->year)->get();
This will work since the year is a string.
Order::whereYear('created_at', (string) Carbon::now()->year)->get();
The text was updated successfully, but these errors were encountered: