parse-community / Parse-SDK-iOS-OSX

The Apple SDK for Parse Platform (iOS, macOS, watchOS, tvOS)
https://parseplatform.org
Other
2.81k stars 871 forks source link

feat: Add `PFObject.isDataAvailableForKey` to check if data is available for individual key #1756

Closed dplewis closed 7 months ago

dplewis commented 1 year ago

New Pull Request Checklist

Issue Description

This PR avoid crashing when we try to get data from key which is not fetched. You can check if data is available for a PFObject but not by individual key.

Closes: https://github.com/parse-community/Parse-SDK-iOS-OSX/pull/1595

Approach

if user.isDataAvailable(forKey: "username") {
 // ok
}

or

if let username = user["username"] {
// username is available
}
else {
// username is unavailable, please fetch it
}

TODOs before merging

parse-github-assistant[bot] commented 1 year ago

Thanks for opening this pull request!

mtrezza commented 1 year ago

This is in case a key value may exist in the DB, but the key value is not fetched on the SDK side, so the SDK doesn't know the current key value?

codecov[bot] commented 1 year ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 64.25%. Comparing base (b9239d7) to head (bf0234d).

:exclamation: Current head bf0234d differs from pull request most recent head 0dd9a83. Consider uploading reports for the commit 0dd9a83 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1756 +/- ## ======================================= Coverage 64.25% 64.25% ======================================= Files 201 201 Lines 23233 23233 ======================================= Hits 14928 14928 Misses 8305 8305 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

dplewis commented 1 year ago

This is in case a key value may exist in the DB, but the key value is not fetched on the SDK side, so the SDK doesn't know the current key value?

This is correct. I've updated the PR to remove the objectForKey changes.

dplewis commented 7 months ago

@mtrezza This is ready for review

mtrezza commented 7 months ago

Test fails, flaky?

dplewis commented 7 months ago

@mtrezza the CI is broken. Looks like an issue with Ruby and Bundler versioning. Can you fix it?

mtrezza commented 7 months ago

See https://github.com/parse-community/Parse-SDK-iOS-OSX/issues/1777

mtrezza commented 7 months ago

It doesn't have a test, do you want to add one, or shall I merge without it?

dplewis commented 7 months ago

The test exist when this was private. No additional test needed

mtrezza commented 7 months ago

The test exist when this was private.

What does that mean?

dplewis commented 7 months ago

Sorry, I mean the test are there already. No need to write new ones

mtrezza commented 7 months ago

If the test is there already, why doesn't it fail without this PR?

mtrezza commented 7 months ago

Is this a bug fix? From the description is seems so...

This PR avoid crashing when we try to get data from key which is not fetched.

But the PR title seems to be feature.

dplewis commented 7 months ago

This is a feature

parseplatformorg commented 7 months ago

🎉 This change has been released in version 3.0.0