Postgres column names are case sensitive (uppercase / lowercase)
See original GitHub issueHi all,
I’m upgrading from exposed 0.12.1 to 0.17.7, and suddenly my tests are failing. This is because of the casing of the columns. I’ve reverted back to our old Exposed.
In our Exposed classes, our columns are mapped in upper case:
val G: Column<Int> =
integer("G")
but when executing the query, Exposed is doing an insert using a lower case g
:
SQL: [INSERT INTO raw_data.raw ("g") VALUES (?)
Which results in an error:
Caused by: org.postgresql.util.PSQLException: ERROR: column "g" of relation "raw" does not exist
This doesn’t happen for all our columns, we also have columns with spaces in it, which seem to be unaffected.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
PostgreSQL — column names of a table are case-sensitive
All identifiers (including column names) that are not double-quoted are converted to lower case in PostgreSQL. Column names that were ...
Read more >SQL Column Names and Case Sensitivity - Seeq Knowledge
The column names in a select statement are not case sensitive unless quoted. Equal (=) and Not Equal (!=) in a where clause...
Read more >Cannot query Postgres database that has column names with ...
PostgreSQL converts all table column names into lowercase, unless quoted. Drupal's Postgres driver does not quote the table/column/alias ...
Read more >Case Sensitivity Differences for SQL Server and PostgreSQL
SQL Server names are depended on the used collection and can be either case sensitive or not. PostgreSQL names are case sensitive.
Read more >Don't get bit by PostgreSQL case sensitivity
Learn how PostgreSQL case sensitivity works. ... What it actually does is convert your table and column names to lowercase by default.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Be careful if you put quotes in your tablenames – identifiers that Exposed generates, like constraint names for foreign keys, will try to include those quotes verbatim, which breaks horribly, e.g.
fk_"MyTable"_id
.You can explicitly put quotes around case sensitive names:
Generated queries preserve those quotes: