Skip to content

BelongsToMany has many duplicate queries on detail page #6479

@niekdemelker

Description

@niekdemelker

Description:

When using an BelongsToMany field, this will show all related models on the Details page. This request to fetch all relation records however calls the DB many times to fetch the ViaResource model. Sometimes over 20 times in one request (Strange enough Model::preventLazyLoading(! app()->isProduction()) doesn't block this behaviour.).

The logging states this call is done repeatedly from 'Http/Requests/InteractsWithRelatedResources.php:72' and one time from 'Http/Requests/QueriesResources.php:38'.

Detailed steps to reproduce the issue on a fresh Nova installation:

  • run migrations & seeder
  • create nova user
  • Open Nova and navigate to 'service levels' and open the details page of the generated record
  • Open Telescope and search on the tag 'bug' to see the recorded queries of this request

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified bug by the Nova teamfix incomingA fix is in review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions