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

[bindgen] Adding a app_user_as_sync_user helper #7684

Merged
merged 2 commits into from
May 13, 2024

Conversation

kraenhansen
Copy link
Member

What, How & Why?

This introduce a app_user_as_sync_user helper, which can be used by the SDK to downcast an app::User to a SyncUser.

☑️ ToDos

  • 📝 Changelog update
  • 🚦 Tests (or not relevant)
  • C-API, if public C++ API changed
  • bindgen/spec.yml, if public C++ API changed

@kraenhansen kraenhansen added T-Internal no-jira-ticket Skip checking the PR title for Jira reference labels May 9, 2024
@kraenhansen kraenhansen requested a review from kneth May 9, 2024 11:11
@kraenhansen kraenhansen self-assigned this May 9, 2024
@cla-bot cla-bot bot added the cla: yes label May 9, 2024
@kraenhansen kraenhansen force-pushed the kh/bindgen/app-user-as-sync-user branch from 41b53d3 to 41639c9 Compare May 9, 2024 11:13
cppName: app::User
sharedPtrWrapped: SharedUser
properties:
is_logged_in: bool
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this to the SyncUser as this is where it's actually implemented:

bool is_logged_in() const
{
return state() == State::LoggedIn;
}


User:
base: SyncUser
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the declaration of this inheritance, because the SDK emits class User extends SyncUser and I saw assertion failures from the User being passed as a SyncUser into the binding, which just interpreted the shared pointer without performing the downcast.

The line giving resulting in assertion failures (the bindingSyncConfig.user is a JS wrapper of app::User but it expects a wrapper of a SyncUser): https://github.com/realm/realm-js/blob/bf7c0c87c460e4adb3cada31df73b74bfa7f1cfc/packages/realm/src/Realm.ts#L384

This happenes because internal.user is User which extends SyncUser and is therefore a valid value for the user here: https://github.com/realm/realm-js/blob/bf7c0c87c460e4adb3cada31df73b74bfa7f1cfc/packages/realm/src/app-services/SyncConfiguration.ts#L341

Copy link

Pull Request Test Coverage Report for Build kraen.hansen_71

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 93 unchanged lines in 15 files lost coverage.
  • Overall coverage decreased (-0.02%) to 90.756%

Files with Coverage Reduction New Missed Lines %
src/realm/array_mixed.cpp 1 91.91%
src/realm/sync/noinst/server/server_history.cpp 1 63.7%
src/realm/util/file.cpp 1 78.73%
src/realm/util/serializer.cpp 1 90.43%
test/test_query2.cpp 1 98.73%
src/realm/cluster.cpp 2 75.6%
src/realm/object-store/shared_realm.cpp 2 91.89%
src/realm/table_view.cpp 2 92.99%
test/test_util_network.cpp 3 95.44%
src/realm/sync/network/network.cpp 4 87.41%
Totals Coverage Status
Change from base Build 2300: -0.02%
Covered Lines: 213162
Relevant Lines: 234874

💛 - Coveralls

CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Kenneth Geisshirt <kenneth.geisshirt@mongodb.com>
@kraenhansen kraenhansen merged commit b7e545a into master May 13, 2024
5 of 6 checks passed
@kraenhansen kraenhansen deleted the kh/bindgen/app-user-as-sync-user branch May 13, 2024 08:26
@kraenhansen
Copy link
Member Author

Merging before CI is green, as the previous commit was green and this last change was to the changelog 🤞

kneth added a commit that referenced this pull request May 14, 2024
* Adding app_user_as_sync_user

* Update CHANGELOG.md

Co-authored-by: Kenneth Geisshirt <kenneth.geisshirt@mongodb.com>

---------

Co-authored-by: Kenneth Geisshirt <kenneth.geisshirt@mongodb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes no-jira-ticket Skip checking the PR title for Jira reference T-Internal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants