operator does not exist: boolean = 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: boolean = integer

Why it happens

tinyint(1) columns usually become boolean on Postgres. MySQL compares them to 1/0 freely; Postgres does not when the 1 is written into the SQL text (whereRaw, DB::select with a literal, raw joins).

Fix

-- raw SQL: WHERE active = true -- or let Laravel bind it (this works on pgsql): ->where('active', 1)

Tested with pdo_pgsql: a bound 1 is accepted for a boolean column; only a literal 1 in the SQL fails.

The tested fix for every table at once (scripts, a Laravel command, before/after checks): Laravel Postgres Error Fix Pack ($19), item 04.

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