Skip to content

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

Merged
taylorotwell merged 2 commits into
laravel:5.6from
staudenmeir:sqlite-year
May 7, 2018
Merged

[5.6] Allow integer values for whereYear() in SQLite#24115
taylorotwell merged 2 commits into
laravel:5.6from
staudenmeir:sqlite-year

Conversation

@staudenmeir

Copy link
Copy Markdown
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