@@ -4,6 +4,7 @@ using Dates
4
4
using DataFrames
5
5
using DataFrames: eachrow
6
6
using Decimals
7
+ using Infinity
7
8
using Intervals
8
9
using IterTools: imap
9
10
using Memento
990
991
end
991
992
992
993
@testset " Type Conversions" begin
994
+ @testset " Deprecations" begin
995
+ conn = LibPQ. Connection (" dbname=postgres user=$DATABASE_USER " ; throw_error= true )
996
+
997
+ result = execute (conn, " SELECT 'infinity'::timestamp;" )
998
+
999
+ try
1000
+ oid = LibPQ. column_oids (result)[1 ]
1001
+ func = result. column_funcs[1 ]
1002
+
1003
+ # Parsing this will show a depwarn
1004
+ @test (@test_deprecated func (LibPQ. PQValue {oid} (result, 1 , 1 ))) == typemax (DateTime)
1005
+ finally
1006
+ close (result)
1007
+ end
1008
+ close (conn)
1009
+ end
1010
+
993
1011
@testset " Automatic" begin
994
1012
conn = LibPQ. Connection (" dbname=postgres user=$DATABASE_USER " ; throw_error= true )
995
1013
@@ -1212,7 +1230,13 @@ end
1212
1230
(" 'foobar'" , Symbol, :foobar ),
1213
1231
(" 0::int8" , DateTime, DateTime (1970 , 1 , 1 , 0 )),
1214
1232
(" 0::int8" , ZonedDateTime, ZonedDateTime (1970 , 1 , 1 , 0 , tz " UTC" )),
1215
- (" '{{{1,2,3},{4,5,6}}}'::int2[]" , AbstractArray{Int16}, reshape (Int16[1 2 3 ; 4 5 6 ], 1 , 2 , 3 ))
1233
+ (" '{{{1,2,3},{4,5,6}}}'::int2[]" , AbstractArray{Int16}, reshape (Int16[1 2 3 ; 4 5 6 ], 1 , 2 , 3 )),
1234
+ (" 'infinity'::timestamp" , InfExtendedTime{Date}, InfExtendedTime {Date} (∞)),
1235
+ (" '-infinity'::timestamp" , InfExtendedTime{Date}, InfExtendedTime {Date} (- ∞)),
1236
+ (" 'infinity'::timestamptz" , InfExtendedTime{ZonedDateTime}, InfExtendedTime {ZonedDateTime} (∞)),
1237
+ (" '-infinity'::timestamptz" , InfExtendedTime{ZonedDateTime}, InfExtendedTime {ZonedDateTime} (- ∞)),
1238
+ (" '[2004-10-19 10:23:54-02, infinity)'::tstzrange" , Interval{InfExtendedTime{ZonedDateTime}}, Interval {Closed, Open} (ZonedDateTime (2004 , 10 , 19 , 12 , 23 , 54 , tz " UTC" ), ∞)),
1239
+ (" '(-infinity, infinity)'::tstzrange" , Interval{InfExtendedTime{ZonedDateTime}}, Interval {InfExtendedTime{ZonedDateTime}, Open, Open} (- ∞, ∞)),
1216
1240
]
1217
1241
1218
1242
for (test_str, typ, data) in test_data
@@ -1331,6 +1355,41 @@ end
1331
1355
end
1332
1356
end
1333
1357
1358
+ @testset " InfExtendedTime" begin
1359
+ tests = (
1360
+ (" 'infinity'::date" , InfExtendedTime {Date} (∞)),
1361
+ (" '-infinity'::date" , InfExtendedTime {Date} (- ∞)),
1362
+ (" 'infinity'::timestamp" , InfExtendedTime {DateTime} (∞)),
1363
+ (" '-infinity'::timestamp" , InfExtendedTime {DateTime} (- ∞)),
1364
+ (" 'infinity'::timestamptz" , InfExtendedTime {ZonedDateTime} (∞)),
1365
+ (" '-infinity'::timestamptz" , InfExtendedTime {ZonedDateTime} (- ∞)),
1366
+ (" '(-infinity, 2012-01-01]'::daterange" , Interval {Open, Closed} (- ∞, Date (2012 , 1 , 1 ))),
1367
+ (" '(2012-01-01, infinity]'::daterange" , Interval {Open, Closed} (Date (2012 , 1 , 1 ), ∞)),
1368
+ (" '(-infinity, infinity)'::tstzrange" , Interval {InfExtendedTime{ZonedDateTime}, Open, Open} (- ∞, ∞))
1369
+ )
1370
+
1371
+ @testset for (pg_str, obj) in tests
1372
+ result = execute (conn, " SELECT $pg_str = \$ 1" , [obj])
1373
+ @test first (first (result))
1374
+ close (result)
1375
+ end
1376
+ end
1377
+
1378
+ @testset " TimeType" begin
1379
+ tests = (
1380
+ (" '2012-01-01'::date" , Date (2012 , 1 , 1 )),
1381
+ (" '01:01:01.01'::time" , Time (1 , 1 , 1 , 10 )),
1382
+ (" '2012-01-01 01:01:01.01'::timestamp" , DateTime (2012 , 1 , 1 , 1 , 1 , 1 , 10 )),
1383
+ (" '2012-01-01 01:01:01.01 UTC'::timestamptz" , ZonedDateTime (2012 , 1 , 1 , 1 , 1 , 1 , 10 , tz " UTC" )),
1384
+ )
1385
+
1386
+ @testset for (pg_str, obj) in tests
1387
+ result = execute (conn, " SELECT $pg_str = \$ 1" , [obj])
1388
+ @test first (first (result))
1389
+ close (result)
1390
+ end
1391
+ end
1392
+
1334
1393
close (conn)
1335
1394
end
1336
1395
0 commit comments