I have an Ecto.Type Size that maps to postgres composite type size.
I can encode a Size parameter but can’t encode an array of Size.
Here some details, the postgres type
CREATE TYPE size AS (value numeric, unit varchar(255))
The Ecto.Type has a basic implementation, type/1, cast/1, dump/1 and load/1 (I omit the details).
Encode a Size parameter works (A):
> q = from(d in Display, where: d.size == type(^s43, Size) and d.id == 1440, select: d.id); Repo.to_sql(:all, q)
{"SELECT d0.\"id\" FROM \"displays\" AS d0 WHERE ((d0.\"size\" = $1::size) AND (d0.\"id\" = 1440))",
[{43, "inch"}]}
> Repo.all(q)
[1440]
But encode an array of Size does not (B):
q = from(d in Display, where: d.size in type(^[{43, "inch"}], {:array, Size}) and d.id == 1440, select: d.id); Repo.to_sql(:all, q)
{"SELECT d0.\"id\" FROM \"displays\" AS d0 WHERE (d0.\"size\" = ANY($1) AND (d0.\"id\" = 1440))",
[[{43, "inch"}]]}
Repo.all(q)
** (DBConnection.EncodeError) cannot encode anonymous tuple {43, "inch"}. Please define a custom Postgrex extension that matches on its underlying type:
use Postgrex.BinaryExtension, type: "typeinthedb"
It looks like some typing was lost there, when I use {:array, Size}, I want to mean size[].
Note that provide explicit cast of param to size[] works, at the sql level:
Repo.query!("select id from displays where size=any($1::size[]) and id=1440", [[{43, "inch"}]]).rows
[[1440]]
Is there something missing in my ecto expression (B)?






















