Uploaded image for project: 'Realm Core'
  1. Realm Core
  2. RCORE-1090

Realm Sync client should not set _id field if not needed

    • Type: Icon: Task Task
    • Resolution: Cannot Reproduce
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None

      Expected results

      Trying to insert into a collection that does not support pk alterations should not fail using Rules.

      Actual Results

      Since sync client tries to always set pk field _id, if the schema does not support alternation of the pk, the insertion will fail.
      Eg this schema does not allow _id alternations, thus insertion will always fail (since we are setting _id in the sync client):

      {
         "collection": "momentInteractions",
          "database": "db",
           "roles": [
           { 
               "name": "creator",
                "apply_when": {},
                "fields": {
                "_id": {
                            "write": false
                 },
                 "viewer": {
                           "write": true
                  },
                 "isPermitted": {
                          "write": true
                 }
            },
            "read": true,
            "insert": true,
            "delete": false,
            "search": false}]
      }
      

      Steps & Code to Reproduce

      1. Using Rules, set up a schema in mongo db atlas that does not support alternation to primary keys.
      2. Try to insert into the collection.
      3. Insertion will fail, reporting that the constraint around the PK has not been respected.

            Assignee:
            nicola.cabiddu@mongodb.com Nicola Cabiddu
            Reporter:
            nicola.cabiddu@mongodb.com Nicola Cabiddu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: