Uploaded image for project: 'Realm Cocoa SDK'
  1. Realm Cocoa SDK
  2. RCOCOA-1467

Can't get change notification for LinkingObjects

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None

      How frequently does the bug occur?

      All the time

      Description

      Cannot get notification for keyPaths of a property declared as follows

      // ...
          @Persisted(originProperty: "objectCol")
          var linkingObjects: LinkingObjects<ModernAllTypesObject>
      // ...
          let tokenA = object.observe(keyPaths: ["linkingObjects"], changeBlock)
          let tokenAB = object.observe(keyPaths: [\ModernAllTypesObject.objectCol], changeBlock)
      // ...
      

      Stacktrace & log output

      Unable to find source-code formatter for language: shell. 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
      n/a
      

      Can you reproduce the bug?

      Yes, always

      Reproduction Steps

      I use the test case:

          func testLinkingObjectObservation() {
              let realm = realmWithTestPath()
              let objectA = ObjectWithLinking()
              let objectB = ObjectWithLinking()
              try! realm.write {
                  realm.add(objectA)
                  realm.add(objectB)
                  objectA.objectCol = objectB
              }
      
              let ex_a1 = expectation(description: "linkingObjects should change")
              let ex_a2 = expectation(description: "objectCol should change")
              let ex_b = expectation(description: "linkingObjects property should change")
              let a1 = objectA.observe(keyPaths: [\ModernAllTypesObject.linkingObjects]) { _ in
                  ex_a1.fulfill()
              }
              let a2 = objectA.observe(keyPaths: ["linkingObjects"]) { _ in
                  ex_a2.fulfill()
              }
              let b = objectA.observe(keyPaths: [\ModernAllTypesObject.objectCol]) { _ in
                  ex_b.fulfill()
              }
              try! realm.write {
                  objectA.objectCol = nil
              }
      
              waitForExpectations(timeout: 2, handler: nil)
              a1.invalidate()
              a2.invalidate()
              b.invalidate()
          }
      

      Version

      10.17.0

      What SDK flavour are you using?

      Local Database only

      Are you using encryption?

      No, not using encryption

      Platform OS and version(s)

      Any iOS, MacOS

      Build environment

      Xcode version: 13
      Dependency manager and version: n/a

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: