Fixing the “column does not exist” error in Sequelize + PostgreSQL
I woke to a slack message that an endpoint was hitting 500, an my check it was traced to Sequelize / PostgreSQL error, which I was conversant with while using PgAdmin but missed while using literal in Sequelize
This error:
column "isavailable" does not exist
If you are facing same issue, you’re not alone — and the fix is surprisingly simple.
💡 The cause
When you write raw SQL or Sequelize literals like this:
Sequelize.literal('CASE WHEN isAvailable THEN 1 ELSE 0 END')
Postgres interprets isAvailable
as a lowercase identifier (isavailable
) — which doesn’t exist.
✅ The fix
Wrap the column name in double quotes to make it case-sensitive:
Sequelize.literal('CASE WHEN "isAvailable" THEN 1 ELSE 0 END')
Now Postgres understands that you’re referring to the actual column name exactly as defined.
⚙️ Bonus Tip
To verify what columns really exist in your table, run this in pgAdmin or psql:
SELECT column_name
FROM information_schema.columns
WHERE table_name = 'property';
✨ Takeaway
Always remember:
- PostgreSQL lowercases unquoted identifiers.
- Wrapping column names in
""
makes them exact and avoids this error.
Simple quotes, powerful fix. 💪
Top comments (0)