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

Allow asymmetric objects to contain links to non-embedded objects #6976

Closed
nielsenko opened this issue Sep 14, 2023 · 0 comments · Fixed by #6981
Closed

Allow asymmetric objects to contain links to non-embedded objects #6976

nielsenko opened this issue Sep 14, 2023 · 0 comments · Fixed by #6981
Assignees

Comments

@nielsenko
Copy link
Contributor

Currently having links to regular realm objects is not allowed in asymmetric objects. Trying to define a realm model like this

@RealmModel(ObjectType.asymmetricObject)
class _Asymmetric {
  _Symmetric? symmetric;
  // ...
}

@RealmModel()
class _Symmetric {
  // ...
}

is disallowed by realm-core. Opening a realm with such schema will throw:

  RealmException: Error opening realm at path <redacted>. Error code: 2016 . Message: Schema validation failed due to the following errors:
  - Asymmetric table with property 'Asymmetric.symmetric' of type 'object' cannot have a non-embedded object type.

But it is trivial to work-around this restriction by injecting an embedded object like this:

@RealmModel(ObjectType.asymmetricObject)
class _Asymmetric {
  late List<_Embedded> embeddedObjects;
  // ...
}

@RealmModel(ObjectType.embeddedObject)
class _Embedded {
  late RealmValue any;
  _Symmetric? symmetric;
}

@RealmModel()
class _Symmetric {
  // ...
}

From discussion with BAAS team they don't have any problems with supporting links to non-embedded objects, so I request we lift the restriction in realm-core as well, since it is not really enforced anyway.

@nielsenko nielsenko self-assigned this Sep 15, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 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 a pull request may close this issue.

1 participant