question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Postgres column names are case sensitive (uppercase / lowercase)

See original GitHub issue

Hi 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:open
  • Created 4 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
maxwell-carboncommented, Aug 17, 2021

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.

1reaction
jorpiccommented, Jul 22, 2021

You can explicitly put quotes around case sensitive names:

object MyTable :  Table("\"MyTable\"") {
    val someField = text("\"someField\"")
}

Generated queries preserve those quotes:

INSERT INTO "MyTable" ("someField") VALUES ($1)
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found