Reputation: 119
I have a ruby on rails app in which I am querying for a boolean column, Flag. The code is:
Merchant.where("Flag=?",false)
However this does not work at all and the only result is that the Merchants table does not have a column name "flag". Is there any way to fix this? The column name starts with an uppercase letter, but the search is being done for a lower case "flag"
Upvotes: 1
Views: 183
Reputation: 434875
If the column name was quoted when the table was created then you will have to quote it forever. So, if you started with this:
create table merchants (
-- ...
"Flag" boolean
-- ...
)
Then you'll have to refer to it using
Merchant.where('"Flag" = ?', false)
PostgreSQL normalizes all unquoted identifiers to lower case (not upper case as the standard says), that's why the error message complains about flag
rather than Flag
.
If you can, you might want to rebuild your table with only lower case column names.
Upvotes: 1