LibPQ.jl icon indicating copy to clipboard operation
LibPQ.jl copied to clipboard

LibPQ logs but doesn't throw for nonexistent column names

Open c42f opened this issue 3 years ago • 1 comments

It seems that when getting a nonexistent column from a LibPQ.Row via getproperty, LibPQ logs a mysterious-looking error to stderr but doesn't otherwise indicate failure.

Should this be an exception?

Demo:

julia> conn = LibPQ.Connection("...");
julia> LibPQ.execute(conn, "create table test (a integer, b integer)")
julia> LibPQ.execute(conn, "insert into test values (1,2)")
julia> row = only(LibPQ.execute(conn, "select * from test"))
LibPQ.Row(PostgreSQL result, 1)

julia> row.a
1

julia> row.x
column number -1 is out of range 0..1
missing

The error column number -1 is out of range 0..1 is coming from inside upstream libpq: https://github.com/postgres/postgres/blob/28d1601ad988790c3c53d7ffd24ef6d2366d4457/src/interfaces/libpq/fe-exec.c#L2798-L2810

c42f avatar Dec 08 '20 11:12 c42f

You're right, I think I know how to fix this as well

iamed2 avatar Dec 09 '20 16:12 iamed2