drawdb-io / drawdb-io/drawdb

[BUG] Importing SQL (PostgreSQL) with Foreign Key reference does cause a SyntaxError

Open
#669 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
39.5k
Forks
3.2k
Avg merge
10h 46m
Merged PRs (30d)
16

Description

**Describe the bug**
Importing the provided test SQL (in PostgreSQL dialect) does not work and fails with a false-positive SyntaxError.
The given test SQL is valid in Postgres dialect.

**To Reproduce**
Steps to reproduce the behavior:

1. Open the application
2. Click on "File" -> "Import from SQL"
3. Import an .sql-file with the test content below
5. See error: "SyntaxError [Ln 13, Col 1]: Expected "(", "--", ".", "/*", or [ \t\n\r] but ")" found."

#### Test SQL content:

[ddl_test.sql](https://github.com/user-attachments/files/23216195/ddl_test.sql)
[ddl_test_extended.sql](https://github.com/user-attachments/files/23216218/ddl_test_extended.sql)

```sql
create table test.table1
(
id uuid not null
primary key
);

create table test.table2
(
id uuid not null
primary key,
ref_id uuid
references table1
);
```

**Expected behavior**
The import of the SQL file should work.

**Screenshots**
Image

**Desktop (please complete the following information):**
- OS: Windows
- Browser Chrome

**Additional context**
The second test file is slightly extended (one more column) and results in a different Syntax Error:

```txt
SyntaxError [Ln 12, Col 26]: Expected "(", "--", ".", "/*", [ \t\n\r], or [A-Za-z0-9_\-$一-龥À-ſ] but "," found.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.