Realm Sync client should not set _id field if not needed

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Cannot Reproduce
    • Priority: 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
            Reporter:
            Nicola Cabiddu
            Archiver:
            Marc Greenfield

              Created:
              Updated:
              Resolved:
              Archived: