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

LinkingObjects empty for newly added objects #5598

Closed
humblehacker opened this issue Jan 30, 2018 · 5 comments
Closed

LinkingObjects empty for newly added objects #5598

humblehacker opened this issue Jan 30, 2018 · 5 comments

Comments

@humblehacker
Copy link

humblehacker commented Jan 30, 2018

Goals

Access LinkingObjects on a new object added to a Realm.

Expected results

After adding an object with a LinkingObjects property to a Realm, accessing the LinkingObjects property returns the expected results.

Actual results

The LinkingObjects property returns no results. Note that if I use an object retrieved from a Realm rather than the original object added to the Realm, the LinkingObjects property works as expected.

Steps to reproduce

  1. Define two Object classes with a bidirectional relationship, with a LinkingObjects property that points from child to parent.
  2. Create one object of each class, and connect the child to the parent.
  3. Create a Realm and add the parent object to it.
  4. Access the LinkingObjects property on the child object.

Code sample that highlights the issue

Playground project

Version of Realm and Tooling

ProductName:	Mac OS X
ProductVersion:	10.13.3
BuildVersion:	17D47

/Applications/Xcode-9.2.app/Contents/Developer
Xcode 9.2
Build version 9C40b

/usr/local/bin/pod
Realm (3.1.0)
RealmSwift (3.1.0)

/bin/bash
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)

/usr/local/bin/carthage
0.27.0
(not in use here)

/usr/local/bin/git
git version 2.16.1
@JettF
Copy link

JettF commented Jan 4, 2019

I am experiencing this issue as well on Realm version 3.13.0

@maroony
Copy link

maroony commented Oct 10, 2019

This bug is still present in 3.19.0. What's interesting: If you create a second child object and put it to the parent with the first child object, all is working as expected for the second child.

@amkomatz
Copy link

Any updates or workarounds for this? Our app is facing this issue in several places.

@amkomatz
Copy link

Okay, after further inspection, I can confirm that this is only happening on instances that were inserted into Realm. If you were to do a reload of that object, any LinkingObjects properties work fine. That appears to be the only workaround for now.

@ejm01
Copy link
Contributor

ejm01 commented May 20, 2020

I updated @humblehacker 's project to Swift 5, RealmSwift 4.4.1 and line 33 now shows expected results.

If anyone is still seeing the issue after 4.3.0 (#6834), please comment.

@ejm01 ejm01 closed this as completed May 20, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants