3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ectoで自動生成したSQLでカラム名が重複した際に気になった

Last updated at Posted at 2023-09-24

困ったこと

ecto で同じテーブルをjoinした際に、カラム名が被るので気になった
(実害はなし)

原因

同じテーブルなのでしょうがない

対応

fragmentで別名をつけるのが簡単そう

from (

~~~
select %{
~~~
item_name_1: fragment("i1.name AS item1_name"),
item_name_2: fragment("i2.name AS item2_name")
})
|> Repo.all()
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?