Skip to content
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

Fix convert_tz function in Postgresql #91

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function getSql(SqlWalker $sqlWalker): string
return '"timestamp"('
. $this->getExpressionValue($value, $sqlWalker)
. ')'
. ' AT TIME ZONE ' . $this->getExpressionValue($toTz, $sqlWalker)
. ' AT TIME ZONE ' . $this->getExpressionValue($fromTz, $sqlWalker);
. ' AT TIME ZONE ' . $this->getExpressionValue($fromTz, $sqlWalker)
. ' AT TIME ZONE ' . $this->getExpressionValue($toTz, $sqlWalker);
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
- functions:
- { name: "convert_tz", className: "Oro\\ORM\\Query\\AST\\Functions\\DateTime\\ConvertTz", type: "datetime" }
dql: "SELECT CONVERT_TZ(f.createdAt, '+00:00', '+01:00') FROM Oro\\Entities\\Foo f WHERE f.id = 1"
sql: "SELECT CONVERT_TZ(t0_.created_at, '+00:00', '+01:00') AS sclr_0 FROM test_foo t0_ WHERE t0_.id = 1"
dql: "SELECT CONVERT_TZ(f.createdAt, 'UTC', 'Europe/Kiev') FROM Oro\\Entities\\Foo f WHERE f.id = 1"
sql: "SELECT CONVERT_TZ(t0_.created_at, 'UTC', 'Europe/Kiev') AS sclr_0 FROM test_foo t0_ WHERE t0_.id = 1"
expectedResult:
- "2014-01-04 06:06:07"
- "2014-01-04 07:06:07"

- functions:
- { name: "convert_tz", className: "Oro\\ORM\\Query\\AST\\Functions\\DateTime\\ConvertTz", type: "datetime" }
dql: "SELECT CONVERT_TZ('2014-01-01 00:00:00', '+00:00', '+01:00') FROM Oro\\Entities\\Foo f WHERE f.id = 1"
sql: "SELECT CONVERT_TZ('2014-01-01 00:00:00', '+00:00', '+01:00') AS sclr_0 FROM test_foo t0_ WHERE t0_.id = 1"
dql: "SELECT CONVERT_TZ('2014-01-01 00:00:00', 'UTC', 'Europe/Kiev') FROM Oro\\Entities\\Foo f WHERE f.id = 1"
sql: "SELECT CONVERT_TZ('2014-01-01 00:00:00', 'UTC', 'Europe/Kiev') AS sclr_0 FROM test_foo t0_ WHERE t0_.id = 1"
expectedResult:
- "2014-01-01 01:00:00"
- "2014-01-01 02:00:00"

- functions:
- { name: "convert_tz", className: "Oro\\ORM\\Query\\AST\\Functions\\DateTime\\ConvertTz", type: "datetime" }
Expand All @@ -21,7 +21,7 @@

- functions:
- { name: "convert_tz", className: "Oro\\ORM\\Query\\AST\\Functions\\DateTime\\ConvertTz", type: "datetime" }
dql: "SELECT CONVERT_TZ('2014-01-01 00:00:00', '+01:00', '+03:00') FROM Oro\\Entities\\Foo f WHERE f.id = 1"
sql: SELECT CONVERT_TZ('2014-01-01 00:00:00', '+01:00', '+03:00') AS sclr_0 FROM test_foo t0_ WHERE t0_.id = 1
dql: "SELECT CONVERT_TZ('2014-01-01 00:00:00', 'Europe/Kiev', 'Asia/Baku') FROM Oro\\Entities\\Foo f WHERE f.id = 1"
sql: SELECT CONVERT_TZ('2014-01-01 00:00:00', 'Europe/Kiev', 'Asia/Baku') AS sclr_0 FROM test_foo t0_ WHERE t0_.id = 1
expectedResult:
- "2014-01-01 02:00:00"
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
- functions:
- { name: "convert_tz", className: "Oro\\ORM\\Query\\AST\\Functions\\DateTime\\ConvertTz", type: "datetime" }
dql: "SELECT CONVERT_TZ(f.createdAt, '+00:00', '+01:00') FROM Oro\\Entities\\Foo f WHERE f.id = 1"
sql: SELECT "timestamp"(t0_.created_at) AT TIME ZONE '+01:00' AT TIME ZONE '+00:00' AS sclr_0 FROM test_foo t0_ WHERE t0_.id = 1
dql: "SELECT CONVERT_TZ(f.createdAt, 'UTC', 'Europe/Kiev') FROM Oro\\Entities\\Foo f WHERE f.id = 1"
sql: SELECT "timestamp"(t0_.created_at) AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Kiev' AS sclr_0 FROM test_foo t0_ WHERE t0_.id = 1
expectedResult:
- "2014-01-04 06:06:07"
- "2014-01-04 07:06:07"

- functions:
- { name: "convert_tz", className: "Oro\\ORM\\Query\\AST\\Functions\\DateTime\\ConvertTz", type: "datetime" }
dql: "SELECT CONVERT_TZ('2014-01-01 00:00:00', '+00:00', '+01:00') FROM Oro\\Entities\\Foo f WHERE f.id = 1"
sql: SELECT "timestamp"('2014-01-01 00:00:00') AT TIME ZONE '+01:00' AT TIME ZONE '+00:00' AS sclr_0 FROM test_foo t0_ WHERE t0_.id = 1
dql: "SELECT CONVERT_TZ('2014-01-01 00:00:00', 'UTC', 'Europe/Kiev') FROM Oro\\Entities\\Foo f WHERE f.id = 1"
sql: SELECT "timestamp"('2014-01-01 00:00:00') AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Kiev' AS sclr_0 FROM test_foo t0_ WHERE t0_.id = 1
expectedResult:
- "2014-01-01 01:00:00"
- "2014-01-01 02:00:00"

- functions:
- { name: "convert_tz", className: "Oro\\ORM\\Query\\AST\\Functions\\DateTime\\ConvertTz", type: "datetime" }
Expand All @@ -21,7 +21,7 @@

- functions:
- { name: "convert_tz", className: "Oro\\ORM\\Query\\AST\\Functions\\DateTime\\ConvertTz", type: "datetime" }
dql: "SELECT CONVERT_TZ('2014-01-01 00:00:00', '+01:00', '+03:00') FROM Oro\\Entities\\Foo f WHERE f.id = 1"
sql: SELECT "timestamp"('2014-01-01 00:00:00') AT TIME ZONE '+03:00' AT TIME ZONE '+01:00' AS sclr_0 FROM test_foo t0_ WHERE t0_.id = 1
dql: "SELECT CONVERT_TZ('2014-01-01 00:00:00', 'Europe/Kiev', 'Asia/Baku') FROM Oro\\Entities\\Foo f WHERE f.id = 1"
sql: SELECT "timestamp"('2014-01-01 00:00:00') AT TIME ZONE 'Europe/Kiev' AT TIME ZONE 'Asia/Baku' AS sclr_0 FROM test_foo t0_ WHERE t0_.id = 1
expectedResult:
- "2014-01-01 02:00:00"