Skip to content

[React-Native] Saved entity has undefined id #9482

@dehy

Description

@dehy

Issue Description

With the react-native driver, dataSource.getRepository().save() method does not return the entity with updated id.
Such bug has been previously reported but for postgreSQL and seems to not apply here (eg. #4090).

I have tested it on a bare typescript/nodejs project with sqlite driver but it worked well. Seems to be specific to react-native.
Breaks both on iOS and android.

Expected Behavior

The returned object should contains an updated id.

Actual Behavior

The returned object id is undefined.

Steps to Reproduce

You can find a reproductible project here : https://github.com/dehy/typeorm-issue-9482

const a = new EntityA();
const savedA = await dataSource.getRepository(EntityA).save(a);
console.log(savedA);

// returns {"id": undefined}

const fetchedA = await dataSource.getRepository(EntityA).find({
    where: {
        id: 1,
    },
});
console.log(fetchedA);

// return [{"id": 1}]

My Environment

Using the react-native driver

Dependency Version
Operating System macOS 12.6 on M1 chip
Node.js version 16.16.0
Typescript version 4.8.4
TypeORM version 0.3.10

Additional Context

Relevant Database Driver(s)

DB Type Reproducible
aurora-mysql no
aurora-postgres no
better-sqlite3 no
cockroachdb no
cordova no
expo no
mongodb no
mysql no
nativescript no
oracle no
postgres no
react-native yes
sap no
spanner no
sqlite no
sqlite-abstract no
sqljs no
sqlserver no

Are you willing to resolve this issue by submitting a Pull Request?

  • ✖️ Yes, I have the time, and I know how to start.
  • ✅ Yes, I have the time, but I don't know how to start. I would need guidance.
  • ✖️ No, I don’t have the time, but I can support (using donations) development.
  • ✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions