-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[4.0] Setting datetime fields to real null value for com_content #25760
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
Conversation
|
@Hackwar I don't think the database schema checker/fixer understands this in the schema update for MySQL:
I think it needs a single line statement for each column for the database schema checker/fixer:
You could see that here: |
|
@Hackwar Regarding my comment above: I mean that the database checker will only check the first column modification if you have all in 1 alter table statement. But when the check shows for the first column that the statement has not run yet, it will run the complete statement. So it is formally not correct to have all in 1 statement. On the other hand, it might be necessary that we do it like this in MySQL 8, and maybe also lower, if strict mode is on. I noticed on MySQL 8 that when running such statement for a single column in PhpMyAdmin on MySQL8, I get an SQL error complaining about the other column not having a valid default value. If it turns out we have to do that and so betray the database checker a bit (but it would work), then we have to do that everywhere where this change for real null columns has been made already, because I've seen in schema updates of those PR that they did it like I suggested, with 1 alter table statement for every column. |
|
@Hackwar When running in PhpMyAdmin on MySQL 5.7 with strict mode on, I even have to add the
|
|
@Hackwar I've just tested, it needs 1 statement for each column. I will make PR against your repo. Question is: Don't you want to do the checked_out_time here, too, and close the other PR which does checked_out_time for all? |
|
|
||
| $advClause[] = '(c2.publish_up = ' . $nullDate . ' OR c2.publish_up <= ' . $nowDate . ')'; | ||
| $advClause[] = '(c2.publish_down = ' . $nullDate . ' OR c2.publish_down >= ' . $nowDate . ')'; | ||
| $advClause[] = '(ISNULL(c2.publish_up) OR c2.publish_up <= ' . $nowDate . ')'; |
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.
I think this ISNULL(...) will not work on PostgreSQL @alikon Confirmed?
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.
Meanwhile I've researched and am sure, there is no isnull function in postgresql, it is a mysql special, so you can't use it. I've added the correction to my against your repo.
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.
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.
@Quy Sure? Does it also work with real NULL values?
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.
@Quy I see, it does work.
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.
@Quy But there are places like the one above where ther is not really used a query object used. Should he do that there, too, and use a query object for that?
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.
Here is the initial PR #21901 that did this way to base off of.
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.
for postgresql there are 2 choices
SELECT (Field IS NULL) FROM ...
or
COALESCE() which is ISO/ANSI SQL standards
This reverts commit 0dab899.
Corrections for MySQL and PostgreSQL for Joomla CMS PR joomla#25760
|
I'm going to change the ISNULL to IS NULL and see where the issue in the install SQL is. I would keep the original PR for checked_out and simply provide PRs for everything else and then we can merge everything. |
|
I will of course do the getNullDateTime() call. |
|
Which issue in the install SQL? |
|
some work (for prepared statement) has been done even if in draft wip pr #25179 maybe can help |
| case 'SERVER_UTC': | ||
| // Convert a date to UTC based on the server timezone. | ||
| if ($this->value && $this->value != Factory::getDbo()->getNullDate()) | ||
| if ($this->value && strlen($this->value) && $this->value != Factory::getDbo()->getNullDate()) |
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.
Wouldn't this fit better?
if ($this->value !== NULL && $this->value != Factory::getDbo()->getNullDate())
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.
No, the value could be an empty string, which isn't null.
| break; | ||
| } | ||
|
|
||
| if ($return == '') |
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.
| if ($return == '') | |
| if ($return === '') |
|
|
||
| // Check the publish down date is not earlier than publish up. | ||
| if ($this->publish_down < $this->publish_up && $this->publish_down > $this->_db->getNullDate()) | ||
| if (!is_null($this->publish_up) && !is_null($this->publish_up) && $this->publish_up > $this->publish_down) |
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.
I think we use === NULL not is_null in code style or?
| if (!is_null($this->publish_up) && !is_null($this->publish_up) && $this->publish_up > $this->publish_down) | |
| if ($this->publish_up !== NULL && $this->publish_up !== NULL && $this->publish_up > $this->publish_down) |
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.
@HLeithner We use both it seems, but is_null() we use by far more often.
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.
iirc @mbabker changed it in the frame work from is_null to !== NULL I'm and sure if the coding style says anything about this. At least we should use the same in all places.
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.
is_null() is slower. Also null must be in lowercase.
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.
Our codestyle has no rules regarding that. If you want us to refactor to that, then I would ask to make a separate issue for that. You might want to bring that up in the ATT. 😉
Use $query->isNullDatetime()
|
Replaced by #26295. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/25760. |
This hopefully changes all datetime values for com_content from the pseudo-null-date 0000-00-00 00:00:00 to a real null value.