我正在尝试重命名连接时的列:
# ...............
result = DB[:my_items1].join(:my_items2, id: :my_item2_id).
select([Sequel[:my_items2][:name].as(:my_items_name),
Sequel[:my_items2][:amount].as(:my_item2_amount)
])
# ...............
例外:
Sequel::DatabaseError - PG::SyntaxError: ERROR: syntax error at or near "AS"
LINE 1: SELECT ("my_items2"."name" AS "my_item2_name", "...
^
:
答案 0 :(得分:3)
Dataset #select采用多个参数,而不是单个数组:
result = DB[:my_items1].join(:my_items2, id: :my_item2_id).
select(Sequel[:my_items2][:name].as(:my_items_name),
Sequel[:my_items2][:amount].as(:my_item2_amount)
)