order
をuniq
とどうやって使うことができますか?PostgreSQLでuniqで注文を使う方法
auction.invoices.get_auction_invoices.item_invoices.
joins("INNER JOIN users ON users.id = invoices.usable_id").order("users.first_name").uniq
上記のクエリは私に次のエラーを与える:item_invoices、 - > {合流:
これは
スコープ私のスコープです(:invoice_details).where( "?invoice_details.invoiceable_type ="、 "アイテム")}
範囲:get_auction_invoices、 - > {(:ID =>(item_invoices.skip_cancelled_invoice + donators.skip_cancelled_invoice))}
PG::InvalidColumnReference: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list LINE 1: ...oice_details.invoiceable_type = 'Item') ORDER BY users.firs... : SELECT DISTINCT "invoices".* FROM "invoices" INNER JOIN "invoice_details" ON "invoice_details"."invoice_id" = "invoices"."id" INNER JOIN users ON users.id = invoices.usable_id WHERE "invoices"."eventable_id" = $1 AND "invoices"."eventable_type" = $2 AND "invoices"."id" IN (1132, 1131, 777, 777, 777, 3013, 3024, 3024, 3024, 3024, 3041, 3041, 3013) AND (invoice_details.invoiceable_type = 'Item') ORDER BY users.first_name
どのようにあなたが 'モデルでauction.invoices.get_auction_invoices.item_invoices'を説明しましたか? –
また、生成されたSQLを '#to_sql'としてください。 –
@МалъСкрылевъ、これは私の請求書モデルで定義しているスコープです – djrock