-
Notifications
You must be signed in to change notification settings - Fork 607
Open
Description
How frequently does the bug occur?
Always
Description
After upgrading to 12.14.1, it was discovered that on record update if you pass the same unchanged list attribute value pulled from realm, the list value will be cleared e.g.
const table = this.realm.write(() => {
this.realm.create('Table', {
_id: new Realm.BSON.ObjectId(), // primaryKey
name: "Test List",
values: [1, 2, 3]
})
})
const updatedTable = this.realm.write(() => {
this.realm.create('Table', {
...table,
name: "Updated List",
}, UpdateMode.All)
})
console.log(updatedTable.values); // is now []
This only appears to be happening for lists defined as string, int etc. List objects appears to be solved by #6977
Upgrading to version 12.14.2 did not solve the issue after finding: #6889
Stacktrace & log output
No crash. Just a broken feature in the application.
Can you reproduce the bug?
Always
Reproduction Steps
A test case was added to integration-tests/tests/src/tests/objects.ts
to confirm whether this issue was isolated to my project. The test case fails on the latest copy of main (currently 12.14.2):
const ListSchema: Realm.ObjectSchema = {
name: "ListObject",
primaryKey: "_id",
properties: {
_id: "objectId",
name: "string",
values: { type: "list", objectType: "int", default: [], optional: true },
names: { type: "list", objectType: "string", default: [], optional: true },
},
};
describe("with primary key", () => {
openRealmBeforeEach({ schema: [PersonWithId, CollectionSchema, ListSchema] });
...
describe("with collection", () => {
...
it("updates without list attributes clearing", function (this: Mocha.Context & RealmContext) {
const list = this.realm.write(() =>
this.realm.create(ListSchema.name, {
_id: new Realm.BSON.ObjectId(),
name: "Test List",
values: [1, 2, 3],
names: ["One", "Two", "Three"],
}),
);
expect(list.values.length).equals(3);
expect(list.names.length).equals(3);
const listAfterUpdate = this.realm.write(() => this.realm.create(ListSchema.name, {
...list,
name: "Updated List",
}, UpdateMode.All));
expect(this.realm.objects(ListSchema.name).length).equals(1); // -- Passes
expect(listAfterUpdate.name).equals("Updated List"); // -- Passes
expect(listAfterUpdate.values.length).equals(3); // -- Fails
expect(listAfterUpdate.names.length).equals(3); // -- Fails
});
Version
12.14.2
What services are you using?
Local Database only
Are you using encryption?
Yes
Platform OS and version(s)
android API 35, iOS 18.3, realm 12.14.2, RN 0.76.9
Build environment
No response
Cocoapods version
1.14.3
kraenhansen