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

BookChild global scope is messing with column selection of page/chapter queries #4823

Closed
ssddanbrown opened this issue Feb 1, 2024 · 1 comment
Assignees
Milestone

Comments

@ssddanbrown
Copy link
Member

Specifically:

// Load book slugs onto these models by default during query-time
static::addGlobalScope('book_slug', function (Builder $builder) {
$builder->addSelect(['book_slug' => function ($builder) {
$builder->select('slug')
->from('books')
->whereColumn('books.id', '=', 'book_id');
}]);
});

The addSelect, where no current selection exists, auto selects all columns.
This is leading to way too much data being loaded in where we're trying to be selective, like almost any loading of pages/chapters for lists.

Need to ideally make this select work with others, or otherwise find another route for this.
Will require attention to be payed to what fields are being returned in API responses, as this could now potentially be a backward compatibility break. Relevant to all endpoints showing chapters/pages, maybe including those on parent items (books->show).

@ssddanbrown ssddanbrown added this to the Next Feature Release milestone Feb 1, 2024
@ssddanbrown ssddanbrown self-assigned this Feb 1, 2024
ssddanbrown added a commit that referenced this issue Feb 4, 2024
Removes page/chpater addSelect global query, to load book slug, and
instead extracts base queries to be managed in new static class, while
updating specific entitiy relation loading to use our more efficient
MixedEntityListLoader where appropriate.

Related to #4823
@ssddanbrown
Copy link
Member Author

Addressed within #4827

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant