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

Patches ArrayDatasource by disabling fields-filtering, fixing broken results on hasMany/HABTM scenarios #112

Open
wants to merge 1 commit into
base: 1.3
Choose a base branch
from

Conversation

albertboada
Copy link

Patches Array Datasource by disabling fields-filtering feature, since it was not behaving properly when querying hasMany/HABTM related models (see commit's source code for detailed explanation).

The reason for this patch lies on a strange behaviour in CakePHP 1.3.X's DBO Datasource (https://github.com/cakephp/cakephp/blob/1.3/cake/libs/model/datasources/dbo_source.php#L1230), where $queryData['fields'] is polluted with a fields list from the root model when querying its hasMany/HABTM relationships, thus affecting all the following queries on related models (since $queryData is passed by reference).
This pollution affected the following bit of code in a way that, if no fields for the current relationship were initially specified by the developer when executing a find(), it would unset ALL of them, giving almost blank results.
Since trying to fully understand all the side effects that changing CakePHP's DBO Datasource would carry, and since field-filtering makes almost no sense in terms of optimization on Array Datasources (unlike in SQL), this patch consists in voiding field-filtering on Array Datasource's models.

Any experience on this scenario, anyone?

@albertboada albertboada force-pushed the b/arrayds-fieldsfiltering-hasmany-hatbm branch from 85b6f20 to 33e5be6 Compare October 8, 2014 12:01
…g broken results when querying hasMany/HABTM related models (see commit code for detailed explanation)
@albertboada albertboada force-pushed the b/arrayds-fieldsfiltering-hasmany-hatbm branch from 33e5be6 to 7df88c6 Compare October 8, 2014 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants