Skip to content

Commit 2505ade

Browse files
committed
Move UTCDateTime tests to 'Specified Types' section.
1 parent 4306505 commit 2505ade

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

test/runtests.jl

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,29 +1327,6 @@ end
13271327
finally
13281328
close(result)
13291329
end
1330-
1331-
# Test parsing timestamptz as UTCDateTime
1332-
if data isa ZonedDateTime
1333-
try
1334-
result = execute(
1335-
conn,
1336-
"SELECT $test_str;";
1337-
binary_format=binary_format,
1338-
type_map=Dict(:timestamptz => UTCDateTime),
1339-
)
1340-
1341-
oid = LibPQ.column_oids(result)[1]
1342-
func = result.column_funcs[1]
1343-
parsed = func(LibPQ.PQValue{oid}(result, 1, 1))
1344-
@test isequal(parsed, data)
1345-
@test typeof(parsed) == UTCDateTime
1346-
parsed_no_oid = func(LibPQ.PQValue(result, 1, 1))
1347-
@test isequal(parsed_no_oid, data)
1348-
@test typeof(parsed_no_oid) == UTCDateTime
1349-
finally
1350-
close(result)
1351-
end
1352-
end
13531330
end
13541331

13551332
close(conn)
@@ -1369,6 +1346,13 @@ end
13691346
("'foobar'", Symbol, :foobar),
13701347
("0::int8", DateTime, DateTime(1970, 1, 1, 0)),
13711348
("0::int8", ZonedDateTime, ZonedDateTime(1970, 1, 1, 0, tz"UTC")),
1349+
("0::int8", UTCDateTime, UTCDateTime(1970, 1, 1, 0)),
1350+
("'2004-10-19 10:23:54+00'::timestamptz", UTCDateTime, UTCDateTime(2004, 10, 19, 10, 23, 54)),
1351+
("'2004-10-19 10:23:54-06'::timestamptz", UTCDateTime, UTCDateTime(2004, 10, 19, 16, 23, 54)),
1352+
("'[2010-01-01 14:30-00, 2010-01-01 15:30-00)'::tstzrange", Interval{UTCDateTime}, Interval{Closed, Open}(UTCDateTime(2010, 1, 1, 14, 30), UTCDateTime(2010, 1, 1, 15, 30))),
1353+
("'[2004-10-19 10:23:54-02, 2004-10-19 11:23:54-02)'::tstzrange", Interval{UTCDateTime}, Interval{Closed, Open}(UTCDateTime(2004, 10, 19, 12, 23, 54), UTCDateTime(2004, 10, 19, 13, 23, 54))),
1354+
("'[2004-10-19 10:23:54-02, Infinity)'::tstzrange", Interval{UTCDateTime}, Interval{Closed, Open}(UTCDateTime(2004, 10, 19, 12, 23, 54), UTCDateTime(typemax(DateTime)))),
1355+
("'(-Infinity, Infinity)'::tstzrange", Interval{UTCDateTime}, Interval{Open, Open}(UTCDateTime(typemin(DateTime)), UTCDateTime(typemax(DateTime)))),
13721356
("'{{{1,2,3},{4,5,6}}}'::int2[]", AbstractArray{Int16}, reshape(Int16[1 2 3; 4 5 6], 1, 2, 3)),
13731357
("DATE '2017-01-31'", InfExtendedTime{Date}, InfExtendedTime{Date}(Date(2017, 1, 31))),
13741358
("'infinity'::timestamp", InfExtendedTime{Date}, InfExtendedTime{Date}(∞)),
@@ -1378,6 +1362,10 @@ end
13781362
("'-infinity'::timestamptz", InfExtendedTime{ZonedDateTime}, InfExtendedTime{ZonedDateTime}(-∞)),
13791363
("'[2004-10-19 10:23:54-02, infinity)'::tstzrange", Interval{InfExtendedTime{ZonedDateTime}}, Interval{Closed, Open}(ZonedDateTime(2004, 10, 19, 12, 23, 54, tz"UTC"), ∞)),
13801364
("'(-infinity, infinity)'::tstzrange", Interval{InfExtendedTime{ZonedDateTime}}, Interval{InfExtendedTime{ZonedDateTime}, Open, Open}(-∞, ∞)),
1365+
("'infinity'::timestamptz", InfExtendedTime{UTCDateTime}, InfExtendedTime{UTCDateTime}(∞)),
1366+
("'-infinity'::timestamptz", InfExtendedTime{UTCDateTime}, InfExtendedTime{UTCDateTime}(-∞)),
1367+
("'[2004-10-19 10:23:54-02, infinity)'::tstzrange", Interval{InfExtendedTime{UTCDateTime}}, Interval{Closed, Open}(UTCDateTime(2004, 10, 19, 12, 23, 54), ∞)),
1368+
("'(-infinity, infinity)'::tstzrange", Interval{InfExtendedTime{UTCDateTime}}, Interval{InfExtendedTime{UTCDateTime}, Open, Open}(-∞, ∞)),
13811369
]
13821370

13831371
for (test_str, typ, data) in test_data

0 commit comments

Comments
 (0)