-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Model discovery] Generated code does not seem to be correct #2953
Comments
cc @marvinirwin |
Are we perhaps calling
Yes please. While @model([object Object])
export class Customer extends Entity {
@property({
// ...
})
custid: string;
// ...
}
Juggler supports both forms. For consistency with the rest of LB4, it would be better to use I also noticed that connector-specific options are represented as JSON: {
@property({
// ...
mysql: {"columnName":"name","dataType":"varchar","dataLength":100,"dataPrecision":null,"dataScale":null,"nullable":"Y"},
})
name?: String;
} It would be nice to represent them as a regular TypeScript object, similarly to what I introduced in #2843 for model settings. {
@property({
// ...
mysql: {
columnName: 'name',
dataType: 'varchar',
dataLength:100,
dataPrecision:null,
dataScale:null,
nullable: 'Y'
},
})
name?: String;
} |
I'd like to add on that the It can be corrected by outputing |
Sorry for jumping in as I'm a complete novice to Loopback, but... I generated a model (can't remember how 😞) a few days ago (don't know the version as I updated to the latest just now 😞) which had no compile errors with this code Looks like a regression, but can't be sure... |
@gonadarian, thanks for the info. It's good to know. @bajtos has a suggestion on how to fix
|
Sorry I'm late, If nobody else has started I'll try and create the fix PR in a day or two. |
@marvinirwin, sure, that would be great. |
That look super weird to me! In #2843, I changed the code emitting When I run import {Entity, model, property} from '@loopback/repository';
@model({settings: {}})
export class Product extends Entity {
constructor(data?: Partial<Product>) {
super(data);
}
} |
I think this issue will be fixed by #3015. |
I can confirm that this issue is fixed with latest cli version. Just tried with 1.16.1. But there is a different issue coming up on discovery. I'll raise that separately. |
Thank you @samarpanB for the confirmation. I am closing this issue as fixed then. |
Description / Steps to reproduce / Feature proposal
Using MySQL as the datasource, I created a table called Customer. Command to create the table is as below:
The generated customer model looks like:
There are a few issues in the code:
@model([object Object])
string
instead ofString
?type: 'string',
instead oftype:String
Acceptance Criteria
Fix the generated code (@bajtos had some pointers for each of them, see #2953 (comment)):
@model([object Object])
string
instead ofString
type: 'string',
instead oftype:String
it should be:
The text was updated successfully, but these errors were encountered: