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

@PrimaryGeneratedColumn and save() #11140

Open
1 of 18 tasks
alexrozante opened this issue Nov 19, 2024 · 0 comments
Open
1 of 18 tasks

@PrimaryGeneratedColumn and save() #11140

alexrozante opened this issue Nov 19, 2024 · 0 comments

Comments

@alexrozante
Copy link

Issue description

save() shoudn't try to update "@PrimaryGeneratedColumns"

Expected Behavior

Primary generated columns should receive it´s value at insert time and be "read only" after that.
It should act as @PrimaryColumn {generated: true, update: false} by default, to not require an update privilege to be granted to the user used by the app.

Actual Behavior

@PrimaryGeneratedColumn decorator don't remove the column from the set ... clause of update statements generated by the save() method. So, the user must have update privilege on the column, wich isn´t the best scenario.

Steps to reproduce

Create any MySQL database and a table with a primary key column (auto_increment) and any other non-key column.

Fill with some records and write a code to update the non-key column of a record with a specific ID, sending the changes with .save()

The update query will include a set id_col=value, forcing the database account to have update privilege on that column.

My Environment

Dependency Version
Operating System Linux or Windows
Node.js version v18.19.0
Typescript version 5.0.2
TypeORM version 0.3.12

Additional Context

No response

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