Does anyone know of a way to introspect an Ecto.Query (at compile time)?
Specifically I was looking at a way to know the query select
keys.
For example if I have a query and inspect
it I can see select: [:field1]
, I would like a way to get to the list of fields in the select.
iex> inspect q
#Ecto.Query<from a0 in A, select: [:field1]>
I know schemas have reflection built in via __schema__/1
for example, but I was looking for something similar for an ecto query. I went spelunking in the source, but assume the dynamic nature of the query builder means this wouldn’t be generally feasible. And I don’t want to try and rely on undocumented API or AST traversal.
If anyone knows something I don’t I would be happy to hear about it