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

Add parent access support on embedded objects #1141

Merged
merged 29 commits into from
Dec 22, 2022

Conversation

clementetb
Copy link
Contributor

@clementetb clementetb commented Nov 21, 2022

Add backlinks support for embedded objects through the EmbeddedRealmObject.parent() extension function.

It provides access to the parent in runtime, and does not require defining particular property in the model as we need in backlinks.

closes #1134

@clementetb clementetb self-assigned this Nov 21, 2022
@cla-bot cla-bot bot added the cla: yes label Nov 21, 2022
Copy link
Contributor

@cmelchior cmelchior left a comment

Choose a reason for hiding this comment

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

Nice, only minor comments

@clementetb
Copy link
Contributor Author

Added support for defining backlinks on EmbeddedRealmObjects models.

@@ -844,7 +846,8 @@ class AccessorModifierIrGeneration(private val pluginContext: IrPluginContext) {
private fun IrType.isLinkingObject(): Boolean {
val propertyClassId = this.classifierOrFail.descriptor.classId
val realmBacklinksClassId = realmBacklinksClass.descriptor.classId
return propertyClassId == realmBacklinksClassId
val realmEmbeddedBacklinksClassId = realmEmbeddedBacklinksClass.descriptor.classId
return propertyClassId == realmBacklinksClassId || propertyClassId == realmEmbeddedBacklinksClassId
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I get this? Is realmBacklinksClassId boolean? Would be nice to have the types be part of the properties in this method.

Copy link
Contributor Author

@clementetb clementetb Dec 22, 2022

Choose a reason for hiding this comment

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

realmBacklinksClassId isn't a boolean but a ClassId?. I am going to split the comparison into two methods for clarity.

clementetb and others added 4 commits December 22, 2022 09:34
…t/EmbeddedRealmObjectExt.kt

Co-authored-by: Christian Melchior <christian@ilios.dk>
…t/EmbeddedRealmObjectExt.kt

Co-authored-by: Christian Melchior <christian@ilios.dk>
@clementetb clementetb merged commit 7ece403 into main Dec 22, 2022
@clementetb clementetb deleted the ct/backlinks-embedded-objects branch December 22, 2022 10:39
@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@LinkingObjects doesn't work with EmbeddedRealmObject
3 participants