Kabie
Ecto select from VALUES, is it possible?
How can I achieve such query in Ecto?
postgres=> SELECT * FROM (VALUES (1,2,3,4), (5,6,7,8)) AS foo (a,b,c,d);
a | b | c | d
---+---+---+---
1 | 2 | 3 | 4
5 | 6 | 7 | 8
(2 rows)
Most Liked
hauleth
Wow, nice. That will make some things much easier, however seeing that it it mostly supported then I think that fragment in from should be supported as well in near future.
2
Kabie
Thanks! It works:
"foo"
|> with_cte("foo", as: fragment("""
SELECT * FROM (VALUES (1,2),(3,4)) AS foo (x,y)
"""))
|> select([foo], {foo.x, foo.y})
|> Repo.all()
[debug] QUERY OK source="foo" db=2.7ms queue=0.6ms idle=1721.4ms
WITH "foo" AS (SELECT * FROM (VALUES (1,2),(3,4)) AS foo (x,y)) SELECT f0."x", f0."y" FROM "foo" AS f0 []
[{1, 2}, {3, 4}]
2
Popular in Questions
can someone please explain to me how Enum.reduce works with maps
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)?
Would
mix ecto.rollback -v 200809061...
New
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Hi all,
Trying to get some more clarity over utc_datetime and naive_datetime for Ecto:
The documentation above suggests that while ...
New
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
Other popular topics
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
Using vs code and installed ElixirLS: support and debugger.
And I got an error popped up on start up says
Failed to run ‘elixir’ comma...
New
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New








