Skip to content

Creating objects while in a manual transaction, should either create an object or throw #2638

Open
@kraenhansen

Description

@kraenhansen

Goals

Calls to realm.create() should either create an object or throw (while in a manual transaction).

Expected Results

If realm.create throws, I expect no side-effects on the database (ie. no rows with default values created).

Actual Results

Calling realm.create with missing values, while in a manual transaction throws but also creates an object with default values.

Steps to Reproduce & Code Sample

const Realm = require("realm");
const realm = new Realm({ schema: [ { name: "SomeClass", properties: { name: 'string', age: 'int' } } ] });
realm.beginTransaction();
realm.create('SomeClass', { age: 13 })

☝️ throws

Error: Missing value for property 'SomeClass.name'

Listing the objects afterwards reveals an object was actually created:

realm.objects('SomeClass') //  Results { [0]: RealmObject { [name]: '', [age]: 0 } }

Version of Realm and Tooling

  • Realm JS SDK Version: 3.5.0
  • Node or React Native: N/A
  • Client OS & Version: N/A
  • Which debugger for React Native: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions