Using a dynamic schema prefix inside a fragment

I’ve yet to figure out how to do cross-schema joins in Ecto and I’ve tried a lot. If you manage to figure it out then I’d be ecstatic. :slight_smile:

Unfortunately, I saw your thread about cross schema queries and the answers from @josevalim, but it seems pretty clear that it’s not possible at the moment (unless using a fragment for the other schema).

But in my case the prefix is the same for the whole query, the problem is that it’s a dynamic one. As multi-tenant applications seemed to be the main case for prefix support in Ecto2, I wonder if there is way to let Ecto generate the from prefix.table part inside the fragment.

Also I would prefer to avoid full raw SQL to avoid even more potential SQL injections.