FIX: Preload associations on subcategories when lazy loading categories (#25630)

This commit is contained in:
Daniel Waterworth 2024-02-09 11:48:26 -06:00 committed by GitHub
parent 250ce25ca3
commit 6311a80724
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -159,7 +159,7 @@ class CategoryList
.where(parent_category_id: @categories.map { |c| c.id }) .where(parent_category_id: @categories.map { |c| c.id })
@categories += @categories +=
Category.where( Category.includes(CategoryList.included_associations).where(
"id IN (WITH cte AS (#{categories_with_rownum.to_sql}) SELECT id FROM cte WHERE rownum <= ?)", "id IN (WITH cte AS (#{categories_with_rownum.to_sql}) SELECT id FROM cte WHERE rownum <= ?)",
SUBCATEGORIES_PER_CATEGORY, SUBCATEGORIES_PER_CATEGORY,
) )