U moet widget_steps.name
. toevoegen naar lijst met geselecteerde kolommen:
SELECT DISTINCT "widgets".*, "widget_steps.name" FROM "widgets" INNER JOIN "widget_steps" ON "widget_steps"."widget_id" = "widgets"."id" INNER JOIN "widget_steps" "active_steps_widgets" ON "active_steps_widgets"."id" = "widgets"."active_widget_step_id" WHERE "widgets"."account_id" = 1 AND "widgets"."completed_at" IS NULL AND (("widgets"."sequential" = 't' AND "widget_steps"."assigned_to" = 5 AND "widget_steps"."id" = "widgets"."active_widget_step_id" AND "widget_steps"."completed_at" IS NULL) OR ("widgets"."sequential" = 'f' AND "widget_steps"."assigned_to" = 5 AND "widget_steps"."completed_at" IS NULL)) ORDER BY sequential DESC, widget_steps.name ASC LIMIT 10 OFFSET 0
Dit zou de logica van uw zoekopdracht niet moeten veranderen en zal prima werken.
In Rails kunt u select
. gebruiken methode om lijst met geselecteerde kolommen in te stellen:
Widget.select('"widgets".*, "widget_steps.name"')
Ik hoop dat dit zou helpen.