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.6] Allow integer values for whereYear() in SQLite #24115

Merged
merged 2 commits into from
May 7, 2018
Merged

[5.6] Allow integer values for whereYear() in SQLite #24115

merged 2 commits into from
May 7, 2018

Conversation

staudenmeir
Copy link
Contributor

whereYear() doesn't work with integer values in SQLite:

Post::whereYear('created_at', Carbon::now()->year)->get();          // Doesn't work.
Post::whereYear('created_at', (string) Carbon::now()->year)->get(); // Works.

This is caused by the strict comparison between the string result of strftime() and the integer value. We can solve it by casting the value to a string.

Although the documentation example uses a string, IMHO integers should also work (as they do in MySQL).

Adds SQLite integration tests for date queries.

Fixes #24058.

@taylorotwell taylorotwell merged commit a37aa1c into laravel:5.6 May 7, 2018
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