ecto icon indicating copy to clipboard operation
ecto copied to clipboard

Support `select: map(x, fields), select_merge: %{...}` in source query for insert_all

Open nmk opened this issue 8 months ago • 6 comments

Elixir version

1.16.3

Database and Version

PostgreSQL 15.0

Ecto Versions

master

Database Adapter and Versions (postgrex, myxql, etc)

postgrex

Current behavior

Repo.insert_all(Foo, from x in Foo, select: %{foo: x.foo, bar: x.bar}, select_merge: %{baz: some_fun(x.baz)})

works as intended.

Repo.insert_all(Foo, from x in Foo, select: map(x, [:foo, :bar]), select_merge: %{baz: some_fun(x.baz)})

raises an ArgumentError stating that the source query does not select into a map.

Expected behavior

The above two snippets should both be supported as they should result in the same source query being produced.

I would be happy to take a stab at this if this is indeed the intended behaviour.

nmk avatar Jun 13 '24 09:06 nmk