Should whereBetween respect DatePeriod inclusion/exclusion flags? #58688
Unanswered
HeathNaylor
asked this question in
Ideas
Replies: 1 comment 1 reply
-
|
fyi, #58480 tried to implement this but was closed due to lack of sufficient tests (and explanation?). This might not be all, but when having another try, this would at least have to be included |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Right now
whereBetweenignoresDatePeriod::EXCLUDE_START_DATEandDatePeriod::INCLUDE_END_DATE.For example:
Currently we get this for all permutations regardless of which options are passed to DatePeriod:
DB::table('users')->whereBetween('created_at', $period)->toSql();producesselect * from "users" where "created_at" between ? and ?DB::table('users')->whereNotBetween('created_at', $period)->toSql();producesselect * from "users" where "created_at" not between ? and ?Since BETWEEN is inclusive on both sides respecting these flags would require switching to comparison operators (>, >=, <, <=) when exclusion is passed and
NOT BETWEENwould haveORlogic.What it should produce should look like
select * from "users" where ("created_at" > ? and "created_at" < ?)for theEXCLUDE_START_DATEoption for example.This would be a behavior change since DatePeriod excludes the end date by default which would affect existing code passing CarbonPeriod (which extends DatePeriod). This was brought up in #58092.
Beta Was this translation helpful? Give feedback.
All reactions