Skip to content
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

lb4 discover create invalid property in model file (DB2 IBMI) #9897

Closed
souvrard opened this issue Aug 28, 2023 · 2 comments
Closed

lb4 discover create invalid property in model file (DB2 IBMI) #9897

souvrard opened this issue Aug 28, 2023 · 2 comments
Labels

Comments

@souvrard
Copy link

Describe the bug

Env: DB2 on IBMI whith loopback 4 fresh install

Command:

lb4 discover --models=XXXX

generate XXX.model.ts with invalid @Property:

  @property({
    type: 'string',
    required: true,
    jsonSchema: {nullable: false},
    length: 15,
    generated: ,  <====================  INVALID
  })

The "generated" property has a value on "undefined" ...

I don't know if it is the best solution but for me the following correction fixes the problem:

File loopback/cli/lib/model-discoverer.js, line 89:

before:

    // Delete the null properties so the template doesn't spit out `key: ;`
    if (v === null) {
      delete o[k];
    }

after:

    // Delete the null and undefined properties so the template doesn't spit out `key: ;`
    if (v === null || typeof v === 'undefined') {
      delete o[k];
    }

stephane

Logs

src/models/b-2-butilpf.model.ts:211:16 - error TS1109: Expression expected.                                                                                                                                                                                                                   
211     generated: ,                                                                                                                                                                                                
                   ~                                                                                                                                                                                                
src/models/b-2-butilpf.model.ts:223:16 - error TS1109: Expression expected.                                                                                                                                                                                                                     
223     generated: ,                                                                                                                                                                                                
                   ~                                                                                                                                                                                                
src/models/b-2-butilpf.model.ts:233:16 - error TS1109: Expression expected.                                                                                                                                                                                                                     
233     generated: ,                                                                                                                                                                                                
                   ~                                                                                                                                                                                                
src/models/b-2-butilpf.model.ts:243:16 - error TS1109: Expression expected.                                                                                                                                                                                                                     
243     generated: ,                                                                                                                                                                                                
                   ~                                                                                                                                                                                                
src/models/b-2-butilpf.model.ts:253:16 - error TS1109: Expression expected.                                                                                                                                                                                                                     
253     generated: ,                                                                                                                                                                                                
                   ~                                                                                                                                                                                                
src/models/b-2-butilpf.model.ts:263:16 - error TS1109: Expression expected.                                                                                                                                                                                                                     
263     generated: ,

Additional information

package.json dependencies:

"dependencies": {
"@loopback/boot": "^6.1.2",
"@loopback/core": "^5.1.2",
"@loopback/repository": "^6.1.2",
"@loopback/rest": "^13.1.2",
"@loopback/rest-explorer": "^6.1.2",
"loopback-connector-ibmi": "^1.0.1",
"odbc": "^2.4.8",
"tslib": "^2.0.0"
},
"devDependencies": {
"@loopback/testlab": "^6.1.2",
"@types/mocha": "^10.0.1",
"@types/node": "^16.18.40",
"mocha": "^10.2.0",
"rimraf": "^5.0.1",
"source-map-support": "^0.5.21",
"typescript": "~5.1.6"
}

console output of one column property:

'type: string'
'required: true'
'jsonSchema: [object Object]'
'length: 1'
'precision: null'
'scale: null'
'generated: undefined' <============ undefined
'ibmi: [object Object]'

Reproduction

no AS400 available for reproduction :/

@souvrard souvrard added the bug label Aug 28, 2023
@aaqilniz
Copy link
Contributor

aaqilniz commented Dec 1, 2023

Hi. This bug is happening after merging this PR of mine. I will make a PR soon to have it fixed.

@aaqilniz
Copy link
Contributor

This PR solves the issue.
I am closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

2 participants