@@ -11,6 +11,7 @@ using Memento
1111using Memento. TestUtils
1212using OffsetArrays
1313using SQLStrings
14+ using DBInterface
1415using TimeZones
1516using Tables
1617using UTCDateTimes
@@ -1893,6 +1894,44 @@ end
18931894
18941895 close (conn)
18951896 end
1897+
1898+ @testset " DBInterface integration" begin
1899+ conn = DBInterface. connect (LibPQ. Connection, " dbname=postgres user=$DATABASE_USER " )
1900+ @test conn isa LibPQ. Connection
1901+
1902+ result = DBInterface. execute (
1903+ conn,
1904+ " SELECT typname FROM pg_type WHERE oid = 16" ;
1905+ )
1906+ @test result isa LibPQ. Result
1907+ @test status (result) == LibPQ. libpq_c. PGRES_TUPLES_OK
1908+ @test isopen (result)
1909+ @test LibPQ. num_columns (result) == 1
1910+ @test LibPQ. num_rows (result) == 1
1911+ @test LibPQ. column_name (result, 1 ) == " typname"
1912+ @test LibPQ. column_number (result, " typname" ) == 1
1913+ data = columntable (result)
1914+ @test data[:typname ][1 ] == " bool"
1915+
1916+ qstr = " SELECT \$ 1::double precision as foo, typname FROM pg_type WHERE oid = \$ 2"
1917+ stmt = DBInterface. prepare (conn, qstr)
1918+ result = DBInterface. execute (
1919+ conn,
1920+ qstr,
1921+ (1.0 , 16 );
1922+ )
1923+ @test result isa LibPQ. Result
1924+ @test status (result) == LibPQ. libpq_c. PGRES_TUPLES_OK
1925+ @test isopen (result)
1926+ @test LibPQ. num_columns (result) == 2
1927+ @test LibPQ. num_rows (result) == 1
1928+ @test LibPQ. column_name (result, 1 ) == " foo"
1929+ @test LibPQ. column_name (result, 2 ) == " typname"
1930+
1931+ DBInterface. close! (conn)
1932+ @test ! isopen (conn)
1933+
1934+ end
18961935 end
18971936end
18981937
0 commit comments