-
Notifications
You must be signed in to change notification settings - Fork 9
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
Removing zeroed dates #16
base: master/elche
Are you sure you want to change the base?
Conversation
`<?= $model['column_prefix'].$field['column_name'] ?>` timestamp NULL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to use the explicit syntax NULL DEFAULT NULL
instead of the implicit syntax NULL
for readability.
👍 the zero date is also refused by strict mode |
This will break all the features that compare dates lesser than something. Take this query for example : SELECT * FROM `test` WHERE date < '2016-04-22' It will match the rows with a date whose value is |
16ebd79
to
73eaf45
Compare
I don't think an empty date should be comparable with another. Plus, this can't break existing apps since it will only affect future migrations. |
You PR affect the fields used by the updated/created observer, so there may be features that rely on it and that could make comparison in a query. I'm just saying that this could have side effects, nothing else. |
No breaking change though (and the behaviour you mention will set valid dates). I could find code that has to check for zeroed dates in addition to null, but nothing expecting valid work from it |
Ok, here is an example. I developped a website using the app wizard, dates fields were created with a default empty value, then I developped a behaviour to find all the items that were imported before :
The method executes a query with a condition on the "imported_at" field :
This will return all the items with a date lesser than the date on the current item and thoses with an empty date, that's how mysql works. Then you patch the App Wizard with this PR. Now If I want to create a new application with a model that implements this behaviour, it won't work as expected, because dates with NULL values won't be returned. Breaking change. |
Your behavior is confusing, expect bugs. I would expect items without a valid import date to not have been imported, thus I also do not expect to find them with |
This may break future developments using the behaviour, but it won't break already running apps. |
I understand the generated app is breaking compatibility now, but there is no issue with that right ? |
👍 if published in a major release and/or a note that indicates this change |
👍 |
This removes the default dates
0000-00-00 00:00:00
and replaces it withNULL
, since0000-00-00
it's not a valid date NOR recognized by any API.