Skip to content

Conversation

@ysfks
Copy link
Contributor

@ysfks ysfks commented Oct 23, 2024

This update improves the handling of CascadeQueryListener in scenarios where the model is not cascadable or lacks a primary key. Currently, since CascadeQueryListener is hooked to the QueryExecuted event, it triggers an unnecessary retrieve operation even for models that are not meant to be cascaded or have a null primary key.

In cases such as mass deletion processes, this adds an extra query and processing time, slowing down performance. This PR introduces a condition to check if (!$this->hasCascadingRelations($builder->getModel()) or $keyName === null), preventing the redundant retrieve event, thus optimizing the cascade process and reducing unnecessary overhead.

Key changes:

•	Added checks for non-cascadable models and null primary keys to avoid extra queries and delays.
•	Ensures that only relevant models trigger the cascade action, optimizing performance in mass deletion or similar operations.

@ysfks ysfks changed the title Latest Add condition to skip retrieving models that are not cascadable Oct 23, 2024
@gcphost
Copy link
Contributor

gcphost commented Oct 23, 2024

Looks good to me, can you fix the issues reported with styleci?

@gcphost gcphost merged commit c23a93e into Askedio:master Oct 23, 2024
9 checks passed
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.

2 participants