-
Notifications
You must be signed in to change notification settings - Fork 22
Postgres tables are quoted when created #69
Comments
@matthewmueller this behavior is found in the fields on the tables as well.
None of these are reserved words in Postgres, but result in table creation like depicted below: Which then requires queries like this to fetch items:
Looking further, it seems that Postgres just forces everything to lowercase if it is not surrounded by quotes. Given that the docs recommend PascalCase for models and camelCase for field names, I understand why the team simply wrapped everything in quotes. It is the only way to preserve the case-sensitive formatting in the table names and the field names. This does create some inconsistency for field names without capital letters, since Postgres drops the quotes on its own in that scenario. |
Leaving this here as well for reference: https://lerner.co.il/2013/11/30/quoting-postgresql/ |
It turns out postgres is a bit weird and if we want capitalized models (to match the schema), we'll need to use double quotes. It looks like ActiveRecord also does it this way. Would a possible solution be to lowercase everything? It would mean that |
Based on: https://prisma.slack.com/archives/CKQTGR6T0/p1563892709024100
I can confirm that with:
You can only select the table via
select * from "Post"
.This doesn't work:
select * from Post
.We need to be smarter about what tables need quotes and what tables do not.
The text was updated successfully, but these errors were encountered: