Column name aliasing broke in v 0.2.29
See original GitHub issue~~It looks like bug fix #6870 caused this regression. ~~ Edit from @imnotjames: It seems to be #4760
If you have a table with Primary key and another column with the same name, then the Primary ID name gets precedence. 0.2.28 was working correctly.
Issue Description
We have a table for example called Book which had a DB primary key in the db. But we don’t want to expose this to the users so we have created another column Book_id which has a UUID which we use in our API
@Entity({name: 'website_book'})
export class Book {
@PrimaryGeneratedColumn({
type: 'integer',
name: 'id', <========= 0.2.29 behavior
})
oldBookId: number;
@Column('int', {
nullable: false,
name: 'user_id',
})
user_id: number;
@Column('character varying', {
nullable: false,
unique: true,
length: 38,
name: 'book_id',
})
id: string; <========= 0.2.28 behavior
}
Expected Behavior
" Book.id " should be mapped to (book_id column in the database)
Actual Behavior
" Book.id " is mapped to (id column in the database)
My Environment
Not os or env dependent issue
| TypeORM version : 0.2.29
Relevant Database Driver(s)
-
aurora-data-api
-
aurora-data-api-pg
-
better-sqlite3
-
cockroachdb
-
cordova
-
expo
-
mongodb
-
mysql
-
nativescript
-
oracle
-
postgres
-
react-native
-
sap
-
sqlite
-
sqlite-abstract
-
sqljs
-
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
I can help test the resolution
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (10 by maintainers)
Top Results From Across the Web
0.3.7 (2022-06-29) | TypeORM Docs
BREAKING CHANGES. we do not call JSON.stringify() to json/jsonb column types in Postgres. Instead, we delegate value directly to underlying pg driver.
Read more >typeorm: CHANGELOG
minor breaking change on "conflict*" options - column names used are now automatically escaped.
Read more >Change Log - Hail
The default behavior is False , which is a breaking change from the previous behavior to always copy output files ... This was...
Read more >https://raw.githubusercontent.com/soda-kem/typeorm...
One must use `PrimaryColumnOptions` instead. * minor breaking change on "conflict*" options - column names used are now automatically escaped.
Read more >ORA-00998: "must name this expression with a column alias"
As the error states, you need to make sure your columns all have valid identifiers (and although COUNT(NOMBRE) is a valid expression, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Great. It worked. 😃 Thanks a lot @imnotjames
Hi everyone unfortunately, I have the same problem
TypeOrm use Class-model as table name in the final query
Code :
TYPE ORM QUERY RESULT :