field property in @Column is not recognized
Issue
field property in @Column is not recognized
Versions
- sequelize: 6.25.3
- sequelize-typescript: 2.1.5
- typescript: 4.0.3
Issue type
When i use:
@Column( { type: DataType.String, allowNull: false, field: 'user-name', }, ) userName: number;
The property fiel is not recognized and have query error:
SELECT "id", "userName", .......... FROM "users_props" AS "User";
if you can see it does not create an alias of the field in the query, it makes a change
- [ x] bug report
- [ ] feature request
Actual behavior
I can't set a custom column field
Expected behavior
Set a custom field from data base colum
Steps to reproduce
set a custom field name ejm: field: 'user-name',
Related code
@Column(
{
type: DataType.String,
allowNull: false,
field: 'user-name',
},
)
userName: number;
"sequelize": "^6.33.0",
"sequelize-typescript": "^2.1.5",
my code works well.
Executing (default): SELECT id, createdAt, updatedAt, user-name AS username FROM User AS c WHERE c.id = '1';
Let me add,in parenthesis, you don't need to explictly set the type : DataType.String, for userName. It can infer the type from your ts. It may cause conflict when you set it manually.