operator does not exist: character varying = integer

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

SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: character varying = integer

Why it happens

A string column (phone, code, zip, external_id) is compared with a bare number in raw SQL. MySQL casts silently; Postgres won't guess.

Fix

WHERE phone = '5551234' -- quote it WHERE phone = ? -- or bind it

Tested with pdo_pgsql: a bound value works; only the literal number fails.

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