Can't reference capitalized types in export to Postgresql
Problem
If there is an enum with capital letters in its name, the .sql export is broken such that the enum can't be referenced (or else I haven't been able to figure out how).
Example
Take an example DBML file:
Enum UserRole{
"Super Admin"
"Super Ultra Admin"
}
Table User {
role UserRole
...
}
When I convert that to Postgresql, it looks like:
CREATE TYPE "UserRole" AS ENUM (
'Super Admin',
'Super Duper Admin'
);
CREATE TABLE "User" (
"role" UserRole
)
This seems fine except that SQL loves to ignore capitalization, so upon running the .sql I get ERROR: type "userrole" does not exist. The correct .sql output would have the enum type quoted to reference it correctly:
CREATE TABLE "User" (
"role" "UserRole"
...
)
Attempted workaround
If you use quotes in the DBML like so, you might expect those quotes to carry through to the .sql file:
Table User {
role "UserRole"
...
}
but the above DBML generates the same unquoted SQL, causing the same problem as earlier.
Apologies for the edge case!
This doesn't work with normalized enum name as well. In my case, the dbml look like this:
Enum user.gender {
...
}
Table user.user {
...
gender user.gender [not null]
}
And the exported PostgreSQL as follow:
CREATE TABLE "user"."user" (
...
"gender" user.gender NOT NULL,
)
which output syntax error at or near "user"
Fixed in https://github.com/holistics/dbml/pull/735