Postgrex ** (DBConnection.EncodeError) Postgrex expected a binary, got 1

OK, I guess in the cases of SELECT 1 AS foo WHERE 1 = $1 and SELECT 1 AS foo WHERE $1 = 1, Postgrex has enough information to guess the type of the placeholder (same as the type on the other side of =).

But in the other cases, Postgrex has no clue what type the placeholders are, so it assumes they should be text.