-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Current Behavior
If we run migration on model:
@model()
export class Order extends Entity {
@property({
type: 'number',
id: true,
generated: true,
})
orderId?: number;
@property({
type: 'number',
})
quantity: number;
// other props..
constructor(data?: Partial<Order>) {
super(data);
}
}and check the DB:
Order, it doesn't have the identifier:

We need to specify the column setting (column name esp, should be in lowercase) for the id property to have it on the table:
@model()
export class Order extends Entity {
@property({
type: 'number',
id: true,
generated: true,
mysql: { // this setting allows you to have different names for model and db column
columnName: 'orderid',
dataType: 'integer',
dataLength: null,
dataPrecision: null,
dataScale: 0,
nullable: 'NO',
},
})
orderId?: number;
...
}Expected Behavior
There is no documentation on that ( in LB4 at least).
Should:
- have it documented
- or fix the migration function
Additional information
So far the issue occurs when using MySQL or PostgreSQL as datasource.
Might have something to do with the function
/**
* Get the escaped column name for a given model property
* @param {String} model The model name
* @param {String} property The property name
* @returns {String} The escaped column name
*/
SQLConnector.prototype.columnEscaped = function(model, property) {
return this.escapeName(this.column(model, property));
};and also some escapeIdName functions in connector-postgres,mysql
Acceptance Criteria
- should have it documented on LB4 site ( both migration and migration-cli pages)
- fix how we check the identifier. If it's not an easy fix, should at least warn users that the identifier gets discarded and the column settings needs to be added.
- add test cases ( for MySQL and Postgres at least)
