-
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
fix(cli): emit correct property definitions for built-in types in discovered models #4143
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your refactor and fix is reasonable to me 👍 haven't reviewed the details of tests, but they look good in general.
packages/cli/test/unit/discover/import-discovered-model.test.js
Outdated
Show resolved
Hide resolved
packages/cli/test/unit/discover/import-discovered-model.test.js
Outdated
Show resolved
Hide resolved
LGTM so far 👍 |
Added one more commit to fix The implementation is not as clean as I would like it to be - we have too many different code paths building model template data - but I guess it's good enough for now. The pull request is ready for final review as far as I am concerned. |
Signed-off-by: Miroslav Bajtoš <[email protected]>
… data Extract code converting model definition returned by juggler's discovery function into LB4 model template data, move this code to a new function that can be used independently. Add few basic unit tests to start building fast unit-level test suite verifying how different settings & property definitions are handled by our discovery layer. Signed-off-by: Miroslav Bajtoš <[email protected]>
Signed-off-by: Miroslav Bajtoš <[email protected]>
Before this change, `lb4 discover` will emit property definitions similar to this: @Property({ type: String, }) title: String; This commit fixes the behavior to make it consistent with `lb4 model` and `lb4 import-lb3-models` output: @Property({ type: 'string', }) title: string; Signed-off-by: Miroslav Bajtoš <[email protected]>
Fix `lb4 model` to close the connection to the datasource after the target model was discovered. Before this change, the generator would hang because the connection pool used by some DB connectors was preventing the process from finishing. Signed-off-by: Miroslav Bajtoš <[email protected]>
Before this change, `lb4 model --dataSource` emits property definitions similar to this: @Property({ type: String, }) title: String; This commit fixes the behavior to make it consistent with `lb4 model` and `lb4 import-lb3-models` output: @Property({ type: 'string', }) title: string; Signed-off-by: Miroslav Bajtoš <[email protected]>
578bef7
to
e203deb
Compare
This pull request fixes model discovery to correctly handle built-in types and convert e.g.
type: String
totype: 'string'
, see #3806.I split the change into several smaller commits:
Add snapshots to CLI tests to give us better understanding of what code we are actually scaffolding. This is also needed to have a test that demonstrates the problem!
Refactor the current implementation to make the fix easier: extract helper function converting discovered model to template data, extract
findBuiltintType
helper.These first steps are not changing observable behavior. With the preparations done, we can make the fixes now.
Emit correct property definitions for built-in types from
lb4 discover
.Disconnect the datasource after the model was discovered by
lb4 model
.Emit correct property definitions for built-in types from
lb4 model
.Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated👉 Check out how to submit a PR 👈