-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: API
What happened?
EmbeddedObject.Parent is not returning anything after being added to realm
Repro steps
- Create a new RealmObject() with an EmbeddedObject, IList<EmbeddedObject, or IDictionary<TKey, EmbeddedObject> property
- Add RealmObject to Realm
- Populate the aforementioned property with a new EmbeddedObject()
- Accessing the Parent property of the added EmbeddedObject returns null
Version
10.7.1
What SDK flavour are you using?
Local Database only
What type of application is this?
Console/Server
Client OS and version
Windows 10 Home 20H2 19042.1348
Code snippets
Here's a small program for reproducing the bug
Unable to find source-code formatter for language: cs. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
public class Test_EmbeddedObjects { class Item : RealmObject { public string? Label { get; set; } public ChildItem? ChildItem { get; set; } public IList<ChildItem> ChildItemList { get; } = null!; public IDictionary<string, ChildItem> ChildItemDict { get; } = null!; } class ChildItem : EmbeddedObject { public string? Label { get; set; } } public static void Main() { var config = new InMemoryConfiguration( "meemoo.db" ) { Schema = new Type[] { typeof( Item ), typeof( ChildItem ) } }; var realm = Realm.GetInstance( config ); var item = new Item { Label = "A" }; item.ChildItem = new ChildItem { Label = "b" }; realm.Write( () => { realm.Add( item ); item.ChildItemList.Add( new ChildItem { Label = "c" } ); item.ChildItemDict.Add( "d", new ChildItem { Label = "d" } ); } ); Console.WriteLine( item.ChildItem.Parent != null); // False Console.WriteLine( item.ChildItemList.First().Parent != null); // False Console.WriteLine( item.ChildItemDict.Values.First().Parent != null); // False } }
Stacktrace of the exception/crash you're getting
No response
Relevant log output
No response
- depends on
-
RCORE-340 Expose a Obj::get_parent API
- Closed