Fix for SQLSTATE[42804]: Datatype mismatch: 7 ERROR:  argument of AND must be type boolean, not type text