column "a@x.com" does not exist

Laravel app, just moved from MySQL to PostgreSQL. The full message as Laravel shows it:

SQLSTATE[42703]: Undefined column: 7 ERROR: column "a@x.com" does not exist

Why it happens

If the 'column' in the error is actually a value (an email, a status word), your raw SQL uses double quotes for a string. MySQL treats "text" as a string; Postgres treats it as a column name.

Fix

WHERE email = 'a@x.com' -- single quotes for strings WHERE email = ? -- or bind it

If the name really is a column, check its case: Postgres folds unquoted names to lower case, so a quoted "userId" and userid are different.

More fixes like this one, as tested scripts: Laravel Postgres Error Fix Pack ($19).

Several errors at once? Paste your log into the error matcher. Raw SQL with MySQL syntax: the free SQL translator. Not migrated yet: the free schema risk check finds this kind of problem before the switch. Planning the whole move: Migration Kit ($49, $34.30 with LAUNCH30 until Nov 5).

Other errors after MySQL to Postgres

Published with deed.page