-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[SQLite] Support timezone information on SqlitePlatform::getDateTimeTzFormatString()
#6006
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
ae9f3db
to
9267923
Compare
What would happen to existing apps with SQLite databases after upgrading to a version of DBAL that ships your change? |
Oh, and we need functional tests for this change. Can you investigate if there are already functional tests that cover datetime with TZ? Maybe those are currently skipped for SQLite? |
5355d91
to
48bb432
Compare
d7e4d5c
to
e89adb0
Compare
With all the issues that you're currently uncovering, I wonder if we should deprecate the current |
I agree that would be nice to have a more consistent behavior across platforms, but also, it depends on the behavior we expect about this type and how clear we are in our docs about the results in each case. I think we can indicate that the behavior is not "symmetric" but only works for writing (see #6014), as the same occurs at least with MySQL and PostgreSQL platforms. Just to recap, these are the paths I think we have (just using a numbered list to make it referenceable):
Personally, I prefer 2 and 5,because that is what I expect from a DBAL: handle the value and process it or fail transparently if it is not possible. |
postgresql has 2 different types for timestamp with time zone and timestamp without time zone (the second one assumes that all timestamps are in the same time zone than the default time zone of the database server when doing date manipulation). The existing timestamptz type works fine in postgresql and does the right thing about ensuring that the datetime correspond to the right point in time. Removing the existing tz types would be a bad idea as it would break existing working situation for projects using a platform that supports those tz types without silently falling back to the non-tz types (i.e. Postgresql, Oracle or SQL Server). Disclaimer: when saying that tz types work in those platforms, I'm not including whether |
* | ||
* @link https://dev.mysql.com/doc/refman/8.0/en/date-and-time-literals.html#date-and-time-string-numeric-literals | ||
*/ | ||
public function getDateTimeTzFormatString() |
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.
Overriding getDateTimeTzFormatString
without overriding getDateTimeTzTypeDeclarationSQL
(so that it does not fallback to the non-tz type) will not provide a working implementation of the type (it will actually make things worse than doing the silent fallback consistently)
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'm afraid I'm missing the point here.
AFAIK, there are no specific types on MySQL for TIMESTAMP
nor DATETIME
:
MySQL converts TIMESTAMP values from the current time zone to UTC for storage, and back from UTC to the current time zone for retrieval. (This does not occur for other types such as DATETIME).
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.
The point of the tz type is that it stores a value for a precise datetime, ensuring that when reading it again, we get the same point in time without having to agree on which timezone is implicitly used by the code.
For a tz type, we need to make sure that on insertion, we can provide a timezone and it is not ignored, but also that on reads, we can get a timezone info from the DB.
If MySQL works only with its implicit timezone on reads, it means we cannot support a tz type properly in DBAL (note that I'm not a fan of the fact that DBAL silently falls back to the non-tz type as it hides the fact that your db is not timezone aware anymore).
There is a good reason is the EcmaScript proposal for the Temporal API has separate objects representing ZonedDateTime and PlainDateTime.
There hasn't been any activity on this pull request in the past 90 days, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days. |
There hasn't been any activity on this pull request in the past 90 days, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days. |
This pull request was closed due to inactivity. |
Summary
Do not discard timezone information on SQLite dates.
Closes #5929.
ToDo
getDateTimeTzFormatString()
(one forconvertToDatabaseValue()
and the other forconvertToPHPValue()
) because forINSERT
/UPDATE
the timezone offsets are allowed, but onSELECT
the returned format is always an UTC timestamp (without offset), as it is how MySQL persists the timestamps;);
datetimetz
anddatetimetz_immutable
types regarding platforms where the timezone offset information is lost during persistence (IE: PostgreSQL, MySQL >= 8.0.19).