Fragments in subqueries

387 views
Skip to first unread message

Daniel Gracia

unread,
May 3, 2016, 5:51:35 PM5/3/16
to elixir-ecto
Hello there.

I'm trying to generate a Ecto query with a computed selected field using SQL fragments, however, when I try to use it as a subquery for a join, the following error is spit at runtime:

subquery can only select sources (t) or fields (t.field), got: `fragment(blabla...)` in query

My question is if there any tougher troubles with implementing support for fragments in subqueries, or if it was a deliberate decision. The docs at least don't mention this limitation anywhere.

José Valim

unread,
May 4, 2016, 12:22:03 AM5/4/16
to elixi...@googlegroups.com
It could definitely be done, we just need to use SQL aliases so we can tie the data together. It probably won't make the cut for 2.0 though. Could you please open up an issue anyway? Thank you.
--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-ecto/311ae032-d532-4eed-9c93-60fe2684cd89%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--


José Valim
Skype: jv.ptec
Founder and Director of R&D

Daniel Gracia

unread,
May 4, 2016, 4:18:49 PM5/4/16
to elixir-ecto, jose....@plataformatec.com.br
Thank you for the answer, José!

I will open the issue in the tracker.


It probably won't make the cut for 2.0 though
 
No problem, can I submit a PR to update the docs better pointing out current subquery limitations?

Em quarta-feira, 4 de maio de 2016 01:22:03 UTC-3, José Valim escreveu:
It could definitely be done, we just need to use SQL aliases so we can tie the data together. It probably won't make the cut for 2.0 though. Could you please open up an issue anyway? Thank you.

On Tuesday, May 3, 2016, Daniel Gracia <daniel...@redealumni.com> wrote:
Hello there.

I'm trying to generate a Ecto query with a computed selected field using SQL fragments, however, when I try to use it as a subquery for a join, the following error is spit at runtime:

subquery can only select sources (t) or fields (t.field), got: `fragment(blabla...)` in query

My question is if there any tougher troubles with implementing support for fragments in subqueries, or if it was a deliberate decision. The docs at least don't mention this limitation anywhere.

--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto+unsubscribe@googlegroups.com.

José Valim

unread,
May 5, 2016, 3:46:21 AM5/5/16
to elixi...@googlegroups.com
Thank you! And PRs to improve the docs are always welcome :)



José Valim
Skype: jv.ptec
Founder and Director of R&D

On Wed, May 4, 2016 at 10:18 PM, Daniel Gracia <daniel...@redealumni.com> wrote:
Thank you for the answer, José!

I will open the issue in the tracker.

It probably won't make the cut for 2.0 though
 
No problem, can I submit a PR to update the docs better pointing out current subquery limitations?

Em quarta-feira, 4 de maio de 2016 01:22:03 UTC-3, José Valim escreveu:
It could definitely be done, we just need to use SQL aliases so we can tie the data together. It probably won't make the cut for 2.0 though. Could you please open up an issue anyway? Thank you.

On Tuesday, May 3, 2016, Daniel Gracia <daniel...@redealumni.com> wrote:
Hello there.

I'm trying to generate a Ecto query with a computed selected field using SQL fragments, however, when I try to use it as a subquery for a join, the following error is spit at runtime:

subquery can only select sources (t) or fields (t.field), got: `fragment(blabla...)` in query

My question is if there any tougher troubles with implementing support for fragments in subqueries, or if it was a deliberate decision. The docs at least don't mention this limitation anywhere.

--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto...@googlegroups.com.


--


José Valim
Skype: jv.ptec
Founder and Director of R&D

--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-ecto/dbbd5451-b5a1-4b6e-a5c3-720520af9f10%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages