Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parentheses issue when \copying to postgres from sqlite #462

Open
ptasheq opened this issue May 7, 2024 · 2 comments
Open

Parentheses issue when \copying to postgres from sqlite #462

ptasheq opened this issue May 7, 2024 · 2 comments

Comments

@ptasheq
Copy link

ptasheq commented May 7, 2024

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 ;)

@nineinchnick
Copy link
Member

nineinchnick commented May 8, 2024

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?

@nineinchnick
Copy link
Member

And I use Arch btw ;)

The jokes are true! Arch rocks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants