Luís Ramalho bio photo

Luís Ramalho

Engineering, Product, Business & Management

Twitter LinkedIn Github Stackoverflow

PostgreSQL has case sensitivity and converts column names to lowercase when trying to do an Active Record Query. An error like the one below will occur:

  PG::Error: ERROR:  column "some_column" does not exist
LINE 1: SELECT "some_table".* FROM "some_table"  WHERE (SOME_UPPERCASE_COLUMN = 'some_value')

In order to solve this problem just escape quotes, likes this:

  Class.all(conditions: ["\"SOME_UPPERCASE_COLUMN\" = ?", 'some_value'])

Problem fixed!