I have this query
SELECT * FROM "functions" WHERE (models_mask & 1 > 0)
and the I get the following error:
PGError: ERROR: operator does not exist: character varying & integer
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
The models_mask is an integer in the database. How can I fix this.
Thank you!
Check out the docs on bit operators for Pg.
Essentially
&only works on two like types (usually bit or int), somodel_maskwill have to beCASTed from varchar to something reasonable like bit or int:models_mask::int & 1-or–models_mask::int::bit & b'1'You can find out what types an operator works with using
\doSinpsqlHere is a quick example for more information