问题
I'm trying to rename a column at join:
# ...............
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)
])
# ...............
Exception:
Sequel::DatabaseError - PG::SyntaxError: ERROR: syntax error at or near "AS"
LINE 1: SELECT ("my_items2"."name" AS "my_item2_name", "...
^
:
回答1:
Dataset#select takes multiple arguments, not a single array:
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)
)
来源:https://stackoverflow.com/questions/50793928/cant-join-and-select-in-sequel-pgsyntaxerror