Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Included model scopes break on includes and joins #4

Closed
chrisdpeters opened this issue Jun 2, 2014 · 0 comments
Closed

Included model scopes break on includes and joins #4

chrisdpeters opened this issue Jun 2, 2014 · 0 comments

Comments

@chrisdpeters
Copy link
Collaborator

Example query:

@content_template = current_site.content_templates.live
                                                  .includes(:draft, blocks: :draft, displays: :draft)
                                                  .where(blocks: { trashed_at: nil }, displays: { trashed_at: nil })
                                                  .find(params[:id])

Throws such an exception (in PostgreSQL):

PG::AmbiguousColumn: ERROR: column reference "trashed_at" is ambiguous LINE 1: ...id" WHERE "content_templates"."site_id" = $1 AND (trashed_at... ^ : SELECT DISTINCT "content_templates"."id" FROM "content_templates" LEFT OUTER JOIN "drafts" ON "drafts"."id" = "content_templates"."draft_id" LEFT OUTER JOIN "blocks" ON "blocks"."content_template_id" = "content_templates"."id" LEFT OUTER JOIN "drafts" "drafts_blocks" ON "drafts_blocks"."id" = "blocks"."draft_id" LEFT OUTER JOIN "displays" ON "displays"."content_template_id" = "content_templates"."id" LEFT OUTER JOIN "drafts" "drafts_displays" ON "drafts_displays"."id" = "displays"."draft_id" WHERE "content_templates"."site_id" = $1 AND (trashed_at IS NULL) AND "blocks"."trashed_at" IS NULL AND "displays"."trashed_at" IS NULL AND "content_templates"."id" = $2 LIMIT 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant