Type cast in `from` without schema

Is it possible to manually specify type cast in from interpolation?
Something like Repo.one(from x in "referred_by_table_name", where: x.id == ^id, select: %{result: x}),
when x.id is binary_id, and id is passed in as a string,
because the table is referred to by a table name not a schema, the type cast doesn’t happen.
If there’s a manual way to specify a type cast, it would be great.

1 Like

Use type(^id, :binary_id).


Thanks! I knew I had seen this but couldn’t recall. :slight_smile:

1 Like