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

retrieve rows through a method #31

Merged
merged 3 commits into from Feb 6, 2020
Merged

Conversation

@faustbrian
Copy link
Contributor

faustbrian commented Feb 2, 2020

Rework of #2 due to #2 (comment).

  1. Do we just want to delete all rows instead of doing a full reset of the cache file and thus could assert a count of 0 after the flush call?
  2. I couldn't really think of a good way to test https://github.com/calebporzio/sushi/pull/31/files#diff-1424272f1875ed72070adab615309d88R63-R70 due to point 1.
@faustbrian

This comment has been minimized.

Copy link
Contributor Author

faustbrian commented Feb 2, 2020

Looks like tests will be red until #25 is merged.

throw_unless(is_array($this->rows), new \Exception('Sushi: $rows property not found on model: '.get_class($this)));
$rows = $this->getRows();

throw_unless(is_array($rows), new \Exception('Sushi: $rows property not found on model: '.get_class($this)));

This comment has been minimized.

Copy link
@shadoWalker89

shadoWalker89 Feb 2, 2020

The exception message will be misleading when the developper overrides the getRows() method and doesn't return an array, i think it should be updated if you are going to keep the check there or maybe just move the check and the exception to the default getRows()

@shadoWalker89

This comment has been minimized.

Copy link

shadoWalker89 commented Feb 2, 2020

This PR allows to define getRows() but doesn't allow for a custom check if the cache is valid or not

case file_exists($cachePath) && filemtime($modelPath) === filemtime($cachePath):

The file time check up here should be extracted to a method to allow the developper to override that as well when he overrides the getRows().

@calebporzio

This comment has been minimized.

Copy link
Owner

calebporzio commented Feb 4, 2020

Echoing what @shadoWalker89 said @faustbrian.

This is a good PR, just wondering about the previously discussed ->flushRowCache() and the corresponding check for its existance if using ->getRows().

Sorry if I missed something along the way where you explain your reasoning for leaving them out.

Thanks!

@faustbrian

This comment has been minimized.

Copy link
Contributor Author

faustbrian commented Feb 4, 2020

flushRowCache is always defined at https://github.com/calebporzio/sushi/pull/31/files#diff-26e616adb7433e8dcaa674db64d6dddbR69-R74 so I am not sure what check of existence I should be adding for it or did you mean that the method should usually not exist and use method_exists to check for it and throw in certain scenarios?

The behaviour at the moment is also still the same with getRows at https://github.com/calebporzio/sushi/pull/31/files#diff-26e616adb7433e8dcaa674db64d6dddbR76-R83 where I moved the default $rows property based behaviour into it.

@calebporzio calebporzio merged commit c346035 into calebporzio:master Feb 6, 2020
0 of 49 checks passed
0 of 49 checks passed
P7.4 - L6.* - prefer-lowest - ubuntu-latest P7.4 - L6.* - prefer-lowest - ubuntu-latest
Details
P7.4 - L6.* - prefer-lowest - windows-latest P7.4 - L6.* - prefer-lowest - windows-latest
Details
P7.4 - L6.* - prefer-stable - ubuntu-latest P7.4 - L6.* - prefer-stable - ubuntu-latest
Details
P7.4 - L6.* - prefer-stable - windows-latest P7.4 - L6.* - prefer-stable - windows-latest
Details
P7.4 - L5.8.* - prefer-lowest - ubuntu-latest P7.4 - L5.8.* - prefer-lowest - ubuntu-latest
Details
P7.4 - L5.8.* - prefer-lowest - windows-latest P7.4 - L5.8.* - prefer-lowest - windows-latest
Details
P7.4 - L5.8.* - prefer-stable - ubuntu-latest P7.4 - L5.8.* - prefer-stable - ubuntu-latest
Details
P7.4 - L5.8.* - prefer-stable - windows-latest P7.4 - L5.8.* - prefer-stable - windows-latest
Details
P7.3 - L6.* - prefer-lowest - ubuntu-latest P7.3 - L6.* - prefer-lowest - ubuntu-latest
Details
P7.3 - L6.* - prefer-lowest - windows-latest P7.3 - L6.* - prefer-lowest - windows-latest
Details
P7.3 - L6.* - prefer-stable - ubuntu-latest P7.3 - L6.* - prefer-stable - ubuntu-latest
Details
P7.3 - L6.* - prefer-stable - windows-latest P7.3 - L6.* - prefer-stable - windows-latest
Details
P7.3 - L5.8.* - prefer-lowest - ubuntu-latest P7.3 - L5.8.* - prefer-lowest - ubuntu-latest
Details
P7.3 - L5.8.* - prefer-lowest - windows-latest P7.3 - L5.8.* - prefer-lowest - windows-latest
Details
P7.3 - L5.8.* - prefer-stable - ubuntu-latest P7.3 - L5.8.* - prefer-stable - ubuntu-latest
Details
P7.3 - L5.8.* - prefer-stable - windows-latest P7.3 - L5.8.* - prefer-stable - windows-latest
Details
P7.3 - L5.7.* - prefer-lowest - ubuntu-latest P7.3 - L5.7.* - prefer-lowest - ubuntu-latest
Details
P7.3 - L5.7.* - prefer-lowest - windows-latest P7.3 - L5.7.* - prefer-lowest - windows-latest
Details
P7.3 - L5.7.* - prefer-stable - ubuntu-latest P7.3 - L5.7.* - prefer-stable - ubuntu-latest
Details
P7.3 - L5.7.* - prefer-stable - windows-latest P7.3 - L5.7.* - prefer-stable - windows-latest
Details
P7.3 - L5.6.* - prefer-lowest - ubuntu-latest P7.3 - L5.6.* - prefer-lowest - ubuntu-latest
Details
P7.3 - L5.6.* - prefer-lowest - windows-latest P7.3 - L5.6.* - prefer-lowest - windows-latest
Details
P7.3 - L5.6.* - prefer-stable - ubuntu-latest P7.3 - L5.6.* - prefer-stable - ubuntu-latest
Details
P7.3 - L5.6.* - prefer-stable - windows-latest P7.3 - L5.6.* - prefer-stable - windows-latest
Details
P7.3 - L5.5.* - prefer-lowest - ubuntu-latest P7.3 - L5.5.* - prefer-lowest - ubuntu-latest
Details
P7.3 - L5.5.* - prefer-lowest - windows-latest P7.3 - L5.5.* - prefer-lowest - windows-latest
Details
P7.3 - L5.5.* - prefer-stable - ubuntu-latest P7.3 - L5.5.* - prefer-stable - ubuntu-latest
Details
P7.3 - L5.5.* - prefer-stable - windows-latest P7.3 - L5.5.* - prefer-stable - windows-latest
Details
P7.2 - L6.* - prefer-lowest - ubuntu-latest P7.2 - L6.* - prefer-lowest - ubuntu-latest
Details
P7.2 - L6.* - prefer-lowest - windows-latest P7.2 - L6.* - prefer-lowest - windows-latest
Details
P7.2 - L6.* - prefer-stable - ubuntu-latest P7.2 - L6.* - prefer-stable - ubuntu-latest
Details
P7.2 - L6.* - prefer-stable - windows-latest P7.2 - L6.* - prefer-stable - windows-latest
Details
P7.2 - L5.8.* - prefer-lowest - ubuntu-latest P7.2 - L5.8.* - prefer-lowest - ubuntu-latest
Details
P7.2 - L5.8.* - prefer-lowest - windows-latest P7.2 - L5.8.* - prefer-lowest - windows-latest
Details
P7.2 - L5.8.* - prefer-stable - ubuntu-latest P7.2 - L5.8.* - prefer-stable - ubuntu-latest
Details
P7.2 - L5.8.* - prefer-stable - windows-latest P7.2 - L5.8.* - prefer-stable - windows-latest
Details
P7.2 - L5.7.* - prefer-lowest - ubuntu-latest P7.2 - L5.7.* - prefer-lowest - ubuntu-latest
Details
P7.2 - L5.7.* - prefer-lowest - windows-latest P7.2 - L5.7.* - prefer-lowest - windows-latest
Details
P7.2 - L5.7.* - prefer-stable - ubuntu-latest P7.2 - L5.7.* - prefer-stable - ubuntu-latest
Details
P7.2 - L5.7.* - prefer-stable - windows-latest P7.2 - L5.7.* - prefer-stable - windows-latest
Details
P7.2 - L5.6.* - prefer-lowest - ubuntu-latest P7.2 - L5.6.* - prefer-lowest - ubuntu-latest
Details
P7.2 - L5.6.* - prefer-lowest - windows-latest P7.2 - L5.6.* - prefer-lowest - windows-latest
Details
P7.2 - L5.6.* - prefer-stable - ubuntu-latest P7.2 - L5.6.* - prefer-stable - ubuntu-latest
Details
P7.2 - L5.6.* - prefer-stable - windows-latest P7.2 - L5.6.* - prefer-stable - windows-latest
Details
P7.2 - L5.5.* - prefer-lowest - ubuntu-latest P7.2 - L5.5.* - prefer-lowest - ubuntu-latest
Details
P7.2 - L5.5.* - prefer-lowest - windows-latest P7.2 - L5.5.* - prefer-lowest - windows-latest
Details
P7.2 - L5.5.* - prefer-stable - ubuntu-latest P7.2 - L5.5.* - prefer-stable - ubuntu-latest
Details
P7.2 - L5.5.* - prefer-stable - windows-latest P7.2 - L5.5.* - prefer-stable - windows-latest
Details
continuous-integration/styleci/pr Issues have been identified with 2 files
Details
@faustbrian faustbrian deleted the faustbrian:getrows branch Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.