Skip to content

fix: remove broken organisers eager load on Workshop queries#2683

Merged
mroderick merged 1 commit into
masterfrom
fix/workshop-organisers-preload
Jul 2, 2026
Merged

fix: remove broken organisers eager load on Workshop queries#2683
mroderick merged 1 commit into
masterfrom
fix/workshop-organisers-preload

Conversation

@mroderick

Copy link
Copy Markdown
Collaborator

Problem

PR #2682 introduced a load_events method that eagerly loads :organisers on Workshop:

Workshop.includes(:chapter, :sponsors, :host, :permissions, :organisers)

The organisers association has a scope condition on the join table:

has_many :organisers, -> { where('permissions.name' => 'organiser') }, through: :permissions, source: :members

When Rails preloads this with the separate-query strategy (which it does here because .where(id: [...]) is a simple query), it generates:

SELECT "members".* FROM "members" WHERE "permissions"."name" = 'organiser' AND "members"."id" IN (...)

This references permissions.name without joining permissions, causing PG::UndefinedTable: missing FROM-clause entry for table "permissions".

Context

PR #2679 already fixed this exact same bug for Event and Meeting by removing :organisers from their eager loads. PR #2682 reintroduced it on Workshop in the new load_events method, under the old assumption that Workshop's complex associations still forced Rails to use eager_load (LEFT JOINs). The .where(id: [...]) pattern in load_events triggers preloading instead, so the broken SQL resurfaces.

Fix

Remove :organisers from the Workshop includes in load_events.

Verification

  • Tests pass
  • Deployed to staging and verified /events/past loads successfully (was returning 500 before)

The organisers association has a scope condition on the join table
that Rails' preloader applies without joining the permissions table,
causing PG::UndefinedTable on production data.

This was already fixed for Event and Meeting in PR #2679, but
PR #2682 reintroduced it on Workshop in the new load_events method.
@mroderick mroderick marked this pull request as ready for review July 2, 2026 08:30
@mroderick mroderick merged commit fdcd4a0 into master Jul 2, 2026
8 checks passed
@mroderick mroderick deleted the fix/workshop-organisers-preload branch July 2, 2026 08:30
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

Successfully merging this pull request may close these issues.

1 participant