Parentheses issue when \copying to postgres from sqlite
ptasheq opened this issue · comments
ptasheq commented
Hi Folks,
using both 0.18.1
tag and current master
branch I encountered the following issue:
Given chinook sample sqlite db is at /tmp/chinook.sqlite3
and the following table in postgres database is created:
create table genre(genre_id int generated by default as identity primary key, genre_name text);
I get the following unexpected results:
$ usql --version
usql 0.18.1
$ usql
(not connected)=> \set pgdb connection_string_to_postgres_db
(not connected)=> \set chinookdb sq:///tmp/chinook.sqlite3
(not connected)=> \copy :chinookdb :pgdb 'select GenreId, Name from Genre' 'genre';
error: failed to prepare query to determine target table columns: pq: syntax error at or near "WHERE"
(not connected)=> \copy :chinookdb :pgdb 'select GenreId, Name from Genre' 'genre(genre_id, genre_name)';
error: failed to prepare query to determine target table columns: pq: syntax error at or near ")"
(not connected)=> \copy :chinookdb :pgdb 'select GenreId, Name from Genre' 'genre(genre_id, genre_name';
COPY 25
Obviously, what I'd expect is the syntax error when the right bracket is missing.
More context:
$ go version
go version go1.22.2 linux/amd64
And I use Arch btw ;)
Jan Waś commented
This is a bug in the postgres
driver's Copy function, but the pgx
driver has a different implementation. Can you try it out as a workaround until we can fix it?
Jan Waś commented
And I use Arch btw ;)
The jokes are true! Arch rocks.