Skip to content

Pass in correct schema type for explicit and autodiscovered types#2259

Merged
LaPeste merged 11 commits intomasterfrom
ac/correct-schema-for-autodiscovered-types
Feb 24, 2021
Merged

Pass in correct schema type for explicit and autodiscovered types#2259
LaPeste merged 11 commits intomasterfrom
ac/correct-schema-for-autodiscovered-types

Conversation

@LaPeste
Copy link
Contributor

@LaPeste LaPeste commented Feb 19, 2021

Description

Based on RealmConfigurationBase.ObjectClasses "AdditiveDiscovered" or "AdditiveExplicit" is now appropriately selected and passed to core.
Currently, because of the way core did it, this is a detail only relevant for synced scenarios. I'll talk to James Stone to understand better the why's'.
This PR also adds an additional exception to have a more precise error category when an issue with the schema validation arises.

==================================
UPDATE
I talked with James and he explained that the 2 types of Additive behaviours are purposedly used only for sync-d realms because unreachable embeddedObjects are only problematic for the server. Hence, when the client doesn't sync, there's no reason to check for them as these unreachable objs don't really create an issue; although being logically useless. He added that the only reason why such check had to end up in the client, although only bothering the server, is that when the server received such object,s the message sent back to the client was too obscure for the user to be of help.

Fixes #2193

TODO

  • Changelog entry
  • Tests

@LaPeste LaPeste changed the title Pass in correct schema type for autodiscovered types Pass in correct schema type for explicit and autodiscovered types Feb 19, 2021
CHANGELOG.md Outdated
### Fixed
* Fixed an issue that would result in UWP apps being rejected from the Microsoft Store due to an unsupported API (`__C_specific_handler`) being used. (Issue [#2235](https://github.com/realm/realm-dotnet/issues/2235))
* Fixed a bug where applying multiple `OrderBy` clauses on a query would result in the clauses being appended to each other as if they were `.ThenBy` rather than the last clause replacing the preceding ones. (PR [#2255](https://github.com/realm/realm-dotnet/issues/2255))
* Fixed proper selection of Additive mode (Explicit or Discovered) to pass to the schema builder. This selection is based on whether or not the user has provided a subset of classes to the Realm Schema. More info about this subject can be found [here](https://docs.mongodb.com/realm/dotnet/objects/#provide-a-subset-of-classes-to-your-realm-schema). (PR [#2259](https://github.com/realm/realm-dotnet/pull/2259))
Copy link
Contributor Author

@LaPeste LaPeste Feb 19, 2021

Choose a reason for hiding this comment

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

2 1 issues with this:

  1. I'm not sure this should be considered an issue. After all, it was consciously decided to have a quick change to the breaking changes introduced by the splitting of the schema mode Additive. If we agree on this, maybe internal could be a better section. Although, even internal means like a change when this must be addressed given the new change in core. So, please advice if this is necessary at all and where it should go.
    2. I'm not that happy to have the PR# here just yet. This is because another PR may be needed based on the outcome of the conversation with James.

==== UPDATE
Since James has confirmed that it was chosen by design to have this matter only touch sync'd realms then point #2 isn't relevant anymore.

@LaPeste LaPeste marked this pull request as ready for review February 22, 2021 13:32
Copy link
Member

@nirinchev nirinchev left a comment

Choose a reason for hiding this comment

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

Mostly documentation nits from me + a suggestion to save a few lines of code

CHANGELOG.md Outdated
### Fixed
* Fixed an issue that would result in UWP apps being rejected from the Microsoft Store due to an unsupported API (`__C_specific_handler`) being used. (Issue [#2235](https://github.com/realm/realm-dotnet/issues/2235))
* Fixed a bug where applying multiple `OrderBy` clauses on a query would result in the clauses being appended to each other as if they were `.ThenBy` rather than the last clause replacing the preceding ones. (PR [#2255](https://github.com/realm/realm-dotnet/issues/2255))
* Fixed proper selection of Additive mode (Explicit or Discovered) to pass to the schema builder. This selection is based on whether or not the user has provided a subset of classes to the Realm Schema. More info about this subject can be found [here](https://docs.mongodb.com/realm/dotnet/objects/#provide-a-subset-of-classes-to-your-realm-schema). (PR [#2259](https://github.com/realm/realm-dotnet/pull/2259))
Copy link
Member

Choose a reason for hiding this comment

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

This message is not something users can understand - none of the mentioned types are publicly exposed. We should instead say something like:

When explicitly specifying `SyncConfiguration.ObjectTypes`, added
a check to validate the schema and ensure all `EmbeddedObject`
classes are reachable from a class inheriting from `RealmObject`.

{
// N.B. the values must match their representation in core!
AdditiveDiscovered = 4,
AdditiveExplicit
Copy link
Member

Choose a reason for hiding this comment

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

Let's be explicit about all values.

@LaPeste LaPeste requested a review from nirinchev February 22, 2021 17:20
@LaPeste LaPeste merged commit b30f384 into master Feb 24, 2021
@LaPeste LaPeste deleted the ac/correct-schema-for-autodiscovered-types branch February 24, 2021 11:25
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pass in correct schema type for autodiscovered types

2 participants