laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.5k stars 11.01k forks source link

Bug with "whereDate" methods #18904

Closed projct1 closed 7 years ago

projct1 commented 7 years ago

Description:

$builder->whereTime('remind_at', 'between', [10, 12]);

This not working, because generates this sql: ... and time(remind_at) between 10 Of couse, we can add methods whereDateBetween, whereTimeBetween, etc)

Dylan-DPC-zz commented 7 years ago

@rorc can you take the resulting query and run the query to see if you are getting your desired result?

projct1 commented 7 years ago

@Dylan-DPC As u can see above, result query is and time(remind_at) between 10 (without 12) Actual result must be and time(remind_at) between 10 and 12

Dylan-DPC-zz commented 7 years ago

what happens with whereBetween?

stemis commented 7 years ago

@rorc According to the laravel docs, whereTime only accepts an int as the third parameter, it seems like whereTime was never designed to be used with the between operator

After some testing, none of the functions that use Illuminate\Database\Query\Builder::addDateBasedWhere, accept an array as third argument

https://laravel.com/api/5.4/Illuminate/Database/Query/Builder.html#method_whereTime

projct1 commented 7 years ago

@stemis Yea, and we can improve this, adding between to $operator?

Dylan-DPC-zz commented 7 years ago

@rorc you can use whereBetween('time', 10, 12);