Use time zone when comparing DateTime with string literal

This commit is contained in:
Alexey Milovidov 2020-04-27 01:13:51 +03:00
parent 2f06a7b4c1
commit cac130ad3b
3 changed files with 34 additions and 1 deletions

View File

@ -849,7 +849,7 @@ private:
{ {
time_t date_time; time_t date_time;
ReadBufferFromMemory in(string_value.data, string_value.size); ReadBufferFromMemory in(string_value.data, string_value.size);
readDateTimeText(date_time, in); readDateTimeText(date_time, in, dynamic_cast<const DataTypeDateTime &>(*number_type).getTimeZone());
if (!in.eof()) if (!in.eof())
throw Exception("String is too long for DateTime: " + string_value.toString(), ErrorCodes::TOO_LARGE_STRING_SIZE); throw Exception("String is too long for DateTime: " + string_value.toString(), ErrorCodes::TOO_LARGE_STRING_SIZE);

View File

@ -0,0 +1,4 @@
1557136800 1557169200
1
1
1

View File

@ -0,0 +1,29 @@
DROP TABLE IF EXISTS tztest;
CREATE TABLE tztest
(
timeBerlin DateTime('Europe/Berlin'),
timeLA DateTime('America/Los_Angeles')
)
ENGINE = Memory;
INSERT INTO tztest (timeBerlin, timeLA) VALUES ('2019-05-06 12:00:00', '2019-05-06 12:00:00');
SELECT
toUnixTimestamp(timeBerlin),
toUnixTimestamp(timeLA)
FROM tztest;
SELECT 1
FROM tztest
WHERE timeBerlin = '2019-05-06 12:00:00';
SELECT 1
FROM tztest
WHERE timeLA = '2019-05-06 12:00:00';
SELECT 1
FROM tztest
WHERE '2019-05-06 12:00:00' = timeBerlin;
DROP TABLE tztest;