-
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
postgres connector not returning generated identifier value on create of entity for camelCased identifiers in table #3749
Comments
@agnes512, I believe you've looked into similar topic before. Could you PTAL? Thanks. |
Hi @basavarajvs , I just reproduced the issue.
Have you checked the mode We actually have been seeing this issue for years (loopbackio/loopback-connector-mysql#57). Sorry that we don't have more naming options available for Please let me know if the workaround works, and if you need more help. Thank you! |
I think this may be a bug in {
"name": "Inventory",
"properties": {
"productId": {
"length": 20,
"memory": {
"columnName": "PRODUCT_ID",
"dataLength": 20,
"dataPrecision": null,
"dataScale": null,
"dataType": "varchar",
"nullable": 0,
},
},
},
} If you take a closer look, you'll see that the LB4 property name IMO, @agnes512 can you please double check that |
@bajtos I think the generated
And the @model({settings: {idInjection: false, postgresql: {schema: 'public', table: 'Order'}}})
export class Order extends Entity {
@property({
type: String,
required: true,
id: 1,
postgresql: {"columnName":"id","dataType":"uuid",..},
})
id: String;
@property({
type: String,
required: true,
postgresql: {
"columnName":"customerId",
"dataType":"uuid",
"dataLength":null,
"dataPrecision":null,
"dataScale":null,
"nullable":"NO"},
})
customerid: String;
// name property
@property({
type: Boolean,
required: true,
postgresql: {
"columnName":"isDelivered",
"dataType":"boolean",
"dataLength":null,
"dataPrecision":null,
"dataScale":null,
"nullable":"NO"},
})
isdelivered: Boolean;
...
} I think it does preserve connector-specific property metadata. And LB4 property names are generated in lower-case. |
@agnes512 thank you for checking!
Great! This is an important part, it's good to know that it's working.
I see two problems: (1) (2)
This looks like a bug to me. My expectation is that the discovery mechanism should produce code that works out of the box with the existing database. That's why I was asking about connector-specific metadata - if it was not present, the the connector would not know that |
@agnes512, could you please add the acceptance criteria? Thanks. |
@bajtos @basavarajvs I doubly checked it. I still couldn't reproduce with LB4 and API Explorer. Here's the response I got from the API Explorer: and the datasource: The postgres connector seems working fine to me. I am not sure if the issue is caused by Swagger. |
This feature is tracked by #3343 |
If a Postgres table has camelCased identifier then auto-generated code of loopback does not return the identifier on creating the entity.
Steps to reproduce
Please note that the identifier field for Cutomer table is customerId in
camelCasing
Run loopback discover to create the models.
loopback discover --schema test
Generate repository and controller.
Run "npm start"
In Swagger execute a post request for Customer.
Current Behavior
The Customer entity is created but the response does not have the identifier field populated.
Expected Behavior
On creating an entity with a camelCased identifier the id should be returned in the post request response.
The problem is not reproduced when the identifiers are lowercased.
Link to reproduction sandbox
Additional information
Related Issues
See Reporting Issues for more tips on writing good issues
The text was updated successfully, but these errors were encountered: