Hi,
I'm stuck at an issue. I have a virtual field that I setup as an Ecto.Enum, and I'm trying to make that value into an atom. I have a "friend_status" field, and if there's a friend request that's not been accepted, then it's pending, if it's accepted, then they are friends, and if no field, then they are basically strangers.
I have my case statement working great in a fragment, but it's returning the strings instead of loading the atom. Here's a sample:
from(
...
select: %{ u | friend_status: fragment("CASE WHEN ? THEN 'stranger' ELSE 'pending' END", is_nil(
f.id))}
)
I tried using Ecto.Query.API.type/2 function, but I'm not sure what to put it as, since when I tried just the column name, it doesn't work, it returns an error saying it's a virtual field.
Is there a way to make this work?