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

Clone queries when grouping/getting by type so that mutations are not made across references #312

Merged
merged 1 commit into from
Aug 21, 2023

Conversation

abnegate
Copy link
Member

E.g. Currently:

$queries = [Query::equal('$id', ['123']];
$filters = Query::groupByType()['filters'];

// Changing the attribute of the query in the original array
$queries[0]->setAttribute('_uid');

// Will change the attribute of the query returned by the `groupByType` method, which is unexpected
$filters[0]->getAttribute() === '_uid'

This is an issue from Appwrite because we mutate query attributes in the find function and then pass the same query references to the count function, which means the values are already mutated. Cloning the queries fixes the issue because changes to one array will not affect the other.

@abnegate abnegate requested a review from stnguyen90 August 21, 2023 23:11
@abnegate abnegate merged commit e5353ea into main Aug 21, 2023
@abnegate abnegate deleted the fix-query-references branch November 23, 2023 01:54
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