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

[sqlite3def] errors when a table name in DDL is double-quoted #111

Closed
minoritea opened this issue Apr 21, 2021 · 3 comments
Closed

[sqlite3def] errors when a table name in DDL is double-quoted #111

minoritea opened this issue Apr 21, 2021 · 3 comments

Comments

@minoritea
Copy link

sqlite3def returns error when an input DDL includes double-quoted table names.
I found the error on sqlite3(sometimes sqlite appends double quotes to their DDL automatically, I don't know why but it does so).
However ANSI SQL supports double quoted identifiers, so I guess it might be caused on other DBs(but I have not tested on MySQL and PostgreSQL).
I hope it will cause no errors with double quoted identifiers.

--export output

CREATE TABLE "test_table" (id integer primary key);

Input SQL

CREATE TABLE "test_table" (id integer primary key);

Current output

found syntax error when parsing DDL "CREATE TABLE "test_table" (id integer primary key)": syntax error at position 26 near 'test_table'
exit status 1

Expected output

-- Nothing is modified --

sqldef version

github.com/k0kubun/sqldef v0.9.0 h1:0NLp0jJa7hqJojUu/jWP5P5rjiWvIAKvEirTBJZcCXU=

SQLite3 version

Package: sqlite3
Version: 3.31.1-4ubuntu0.2
Priority: optional
Section: misc
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Laszlo Boszormenyi (GCS) <gcs@debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 2803 kB
Depends: libc6 (>= 2.29), libreadline8 (>= 6.0), zlib1g (>= 1:1.2.0), libsqlite3-0 (= 3.31.1-4ubuntu0.2)
Suggests: sqlite3-doc
Homepage: https://www.sqlite.org/
Download-Size: 860 kB
APT-Manual-Installed: yes
APT-Sources: http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
Description: Command line interface for SQLite 3
 SQLite is a C library that implements an SQL database engine.
 Programs that link with the SQLite library can have SQL database
 access without running a separate RDBMS process.

Installed on WSL2 Ubuntu 20.04 on Windows10(x64) host.

How to reproduce the DDL

CREATE TABLE test_table (id integer primary key);
ALTER TABLE test_table RENAME TO test_table2;
ALTER TABLE test_table2 RENAME TO test_table;

I don't know why, but sqlite3 appends double quotes when I rename a table name.

@minoritea minoritea changed the title errors when a table name in DDL is double-quoted [sqlite3def] errors when a table name in DDL is double-quoted Apr 21, 2021
@minoritea
Copy link
Author

I found an archived issue about the renaming problem.
http://sqlite.1065341.n5.nabble.com/Bug-Report-Quotes-added-to-table-name-after-ALTER-TABLE-RENAME-TO-td75197.html

Probably the behavior is correct on SQLite side.

@k0kubun
Copy link
Collaborator

k0kubun commented Apr 22, 2021

Thanks for reporting it. Please try v0.9.1 which is being released now.

@minoritea
Copy link
Author

Now it works fine! Thank you!

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