#PR - #852 (Bug fixing)
Describe the bug
When importing a SQL script generated by pg_dump (PostgreSQL), the application fails to generate the diagram and displays a "Syntax Error" message. This happens even for valid SQL files because the parser (node-sql-parser) crashes when it encounters standard PostgreSQL dump artefacts like comments (--), configuration commands (SET statement_timeout...), or extensions (CREATE EXTENSION).
To Reproduce
Steps to reproduce the behaviour:
- Generate a dump file from a PostgreSQL database using pg_dump (or use a SQL file containing SET commands or comments).
- Open DrawDB and click File > Import SQL.
- Paste the SQL content or upload the file.
- See error: "Syntax Error due to token..." (or generally failing to load).
Expected behaviour
The application should successfully parse the DDL statements (CREATE TABLE, ALTER TABLE) to generate the diagram, while ignoring non-structural metadata like comments or session variable configurations.
Desktop (please complete the following information):
- OS: macOS / Windows / Linux (Platform Independent)
- Browser Chrome / Firefox / Safari
Additional context
The issue stems from the strictness of the node-sql-parser library. It does not support specific pg_dump meta-commands. A fix involves sanitising the SQL input to strip these artefacts before parsing. I have prepared a PR for this.
#PR - #852 (Bug fixing)
Describe the bug
When importing a SQL script generated by pg_dump (PostgreSQL), the application fails to generate the diagram and displays a "Syntax Error" message. This happens even for valid SQL files because the parser (node-sql-parser) crashes when it encounters standard PostgreSQL dump artefacts like comments (--), configuration commands (SET statement_timeout...), or extensions (CREATE EXTENSION).
To Reproduce
Steps to reproduce the behaviour:
Expected behaviour
The application should successfully parse the DDL statements (CREATE TABLE, ALTER TABLE) to generate the diagram, while ignoring non-structural metadata like comments or session variable configurations.
Desktop (please complete the following information):
Additional context
The issue stems from the strictness of the node-sql-parser library. It does not support specific pg_dump meta-commands. A fix involves sanitising the SQL input to strip these artefacts before parsing. I have prepared a PR for this.