Parse-SDK-iOS-OSX icon indicating copy to clipboard operation
Parse-SDK-iOS-OSX copied to clipboard

feat: Expose `PFObject` `isDataAvailableForKey`

Open dplewis opened this issue 2 years ago • 4 comments

New Pull Request Checklist

  • [ ] I am not disclosing a vulnerability.
  • [ ] I am creating this PR in reference to an issue.

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

  • [x] Add tests
  • [x] Add changes to documentation (guides, repository pages, in-code descriptions)

dplewis avatar Oct 07 '23 14:10 dplewis

Thanks for opening this pull request!

  • 🎉 We are excited about your hands-on contribution!

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?

mtrezza avatar Oct 07 '23 23:10 mtrezza

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
@@           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.

codecov[bot] avatar Oct 18 '23 21:10 codecov[bot]

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 avatar Oct 26 '23 06:10 dplewis

@mtrezza This is ready for review

dplewis avatar Apr 05 '24 22:04 dplewis

Test fails, flaky?

mtrezza avatar Apr 06 '24 00:04 mtrezza

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

dplewis avatar Apr 06 '24 00:04 dplewis

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

mtrezza avatar Apr 06 '24 12:04 mtrezza

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

mtrezza avatar Apr 06 '24 19:04 mtrezza

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

dplewis avatar Apr 06 '24 21:04 dplewis

The test exist when this was private.

What does that mean?

mtrezza avatar Apr 06 '24 21:04 mtrezza

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

dplewis avatar Apr 06 '24 21:04 dplewis

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

mtrezza avatar Apr 06 '24 22:04 mtrezza

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.

mtrezza avatar Apr 06 '24 22:04 mtrezza

This is a feature

dplewis avatar Apr 06 '24 22:04 dplewis

🎉 This change has been released in version 3.0.0

parseplatformorg avatar Apr 08 '24 14:04 parseplatformorg