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

Fixed $model->countRelated() failing when the relation is reusable #14444

Merged
merged 11 commits into from Oct 13, 2019

Conversation

@zsilbi
Copy link
Contributor

zsilbi commented Oct 3, 2019

Hello!

  • Type: bug fix

In raising this pull request, I confirm the following:

  • I have read and understood the Contributing Guidelines
  • I have checked that another pull request for this purpose does not exist
  • I wrote some tests for this PR
  • I have updated the relevant CHANGELOG
  • I have created a PR for the documentation about this change

Small description of change:

The uniqueKey used to store reusable related records in ModelsManager is currently generated only from the conditions used to lookup the records.

For example:
It uses the same key for $robot->getParts(["some" = "thing"]) and $robot->countParts(["some" = "thing"]).
If the related records are accessed again using a different method, it will return the result of the first.
In this case, it will be a Resultset instead of an integer.

I added the retrieveMethod variable to the uniqueKey generation.
Added some tests for Model::__call()

Thanks,
zsilbi

@zsilbi zsilbi changed the title [WIP] Fixed Model::countRelated() failing when the relation is reusable [WIP] Fixed $model->countRelated() failing when the relation is reusable Oct 3, 2019
@zsilbi

This comment has been minimized.

Copy link
Contributor Author

zsilbi commented Oct 12, 2019

@sergeyklay I'd also change Model::__callStatic() to throw an exception if the method is unknown, like Model::__call() does.

What do you think?

@niden niden added this to In progress in 4.0 Release via automation Oct 12, 2019
@sergeyklay

This comment has been minimized.

Copy link
Member

sergeyklay commented Oct 13, 2019

@zsilbi Let's use a separated PR to change Model::__callStatic()

zsilbi added 9 commits Oct 3, 2019
retrieve method (find, findFirst, count.. etc.)
New RobotsReusable model for testing reusable relation
null. Therefore it should return false, instead of null when the
requested method doesn't exist.
_getRelatedRecords returns null. Therefore it should return false,
instead of null when the requested relation doesn't exist.
@codecov

This comment has been minimized.

Copy link

codecov bot commented Oct 13, 2019

Codecov Report

Merging #14444 into 4.0.x will increase coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##            4.0.x   #14444      +/-   ##
==========================================
+ Coverage   67.67%   67.68%   +0.01%     
==========================================
  Files         482      482              
  Lines      111229   111235       +6     
==========================================
+ Hits        75275    75294      +19     
+ Misses      35954    35941      -13
@zsilbi zsilbi force-pushed the zsilbi:model-reusable-records branch from e44ca54 to 93ae076 Oct 13, 2019
Németh Balázs
@zsilbi zsilbi changed the title [WIP] Fixed $model->countRelated() failing when the relation is reusable Fixed $model->countRelated() failing when the relation is reusable Oct 13, 2019
@zsilbi zsilbi requested a review from sergeyklay Oct 13, 2019
@niden niden added Docs needed and removed WIP labels Oct 13, 2019
@niden niden merged commit cf397d0 into phalcon:4.0.x Oct 13, 2019
4.0 Release automation moved this from In progress to Done Oct 13, 2019
@niden

This comment has been minimized.

Copy link
Member

niden commented Oct 13, 2019

Thank you @zsilbi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
4.0 Release
  
Done
4 participants
You can’t perform that action at this time.