You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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
Additional Context
No response
Relevant Database Driver(s)
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.
The text was updated successfully, but these errors were encountered: