Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong behaviour of save() method #9753

Open
1 of 18 tasks
danikp opened this issue Feb 2, 2023 · 0 comments
Open
1 of 18 tasks

wrong behaviour of save() method #9753

danikp opened this issue Feb 2, 2023 · 0 comments

Comments

@danikp
Copy link

danikp commented Feb 2, 2023

Issue description

save() method, if getting object with id attribute, using it for SELECT query, but ignoring for INSERT

Expected Behavior

expacted behaviour isthat entry will be inserted withh allattributes passed, including id, meaning, if I save following object
{id: 5, name: "test"} produced SQL will be

  1. SELECT id, name FROM some_table WHERE id=5
  2. and if not found INSERT INTO some_table (id, name) VALUES(5, "test")

Actual Behavior

currentlywhile first SELECt query produced as expected, second INSERT query missing id field and interted and lastinsert sequence and not at place expected, query looks like INSERT INTO some_table (name) VALUES("test")

Steps to reproduce

pseudo code
const saveObject = {id: 5, name: "test"}
await queryRunner.manager.save(SomeEntity, saveObject);

My Environment

Dependency Version
TypeORM version 0.3.11

Additional Context

tested on postgres, but may be relevant to all drivers

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

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

No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant