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

parse failure with CREATE TABLE main.TableName #31

Open
bradfitz opened this issue Apr 20, 2024 · 0 comments
Open

parse failure with CREATE TABLE main.TableName #31

bradfitz opened this issue Apr 20, 2024 · 0 comments

Comments

@bradfitz
Copy link
Contributor

sqlite lets you create a table main.Foo

https://www.sqlite.org/lang_attach.html says:

The schema-names 'main' and 'temp' refer to the main database and the database used for temporary tables. The main and temp databases cannot be attached or detached.

Tables in an attached database can be referred to using the syntax schema-name.table-name. If the name of the table is unique across all attached databases and the main and temp databases, then the schema-name prefix is not required.

Example:

% sqlite3
SQLite version 3.43.2 2023-10-10 13:08:14
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> create table main.bar (x integer);
sqlite> create table foo.bar (x integer);
Parse error: unknown database foo
  create table foo.bar (x integer);
               ^--- error here
sqlite> 

But this repo wants just an identifier: see https://go.dev/play/p/5TiIUqNTy3W for an error:

	p := sql.NewParser(strings.NewReader("CREATE TABLE main.T1 (C1 TEXT PRIMARY KEY, C2 INTEGER)"))
	_, err := p.ParseStatement()
	if err != nil {
		t.Logf("error: %v", err)
	}

=>

=== RUN   TestCreateTableDot
    prog_test.go:14: error: 1:18: expected AS or left paren, found '.'
--- PASS: TestCreateTableDot (0.00s)
PASS

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

1 participant