-
Notifications
You must be signed in to change notification settings - Fork 62
Description
Hello,
I've opened a few issues in other model-specific repositories on the same topic - sometimes properties in YAML files that are used as a base for SQL schema file generation are also valid keywords in PostgreSQL (DuckDB and other PostgreSQL-compatible databases as well).
This causes the resulting schema.sql files to be unusable - they can't be applied without modification.
I believe that generate_sql_schema is used to generate all those schema.sql files in model repositories?
I propose a simple fix - let's just quote all the column names in the CREATE TABLE statements. I wouldn't personally add a keyword blacklist for exceptions since that isn't future proof and would eventually break the generator if a keyword would be added or removed to PostgreSQL. Different PostgreSQL compatible (SQL syntax) databases can also potentially have some keyword differences 🤷
Changing the few sql_schema_statements.append(f"{key} {field_type}") (and similar) lines would probably be enough to fix this issue. Something like sql_schema_statements.append(f"\"{key}\" {field_type}").
Thank you!