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

Entity fields default values #25633

Merged
merged 1 commit into from
Apr 15, 2024

Conversation

OmarHawk
Copy link
Contributor

@OmarHawk OmarHawk commented Mar 26, 2024

Fixes #25094

Also I used the opportunity to unify the conditions used in the incremental generator for writing the actual liquibase xml files and producing the references in master.xml and making sure they are also the same conditions as in the actual templates. This was inconsistent before.

I only saw in the Angular generator an easy way to introduce default values there. In the others, there are no means at all for default values: React one would require an update of the corresponding dependency - and vue.js, I really don't have a clue about that.

If the merge request is OK in general, I'll also enhance the documentation.


Please make sure the below checklist is followed for Pull Requests.

When you are still working on the PR, consider converting it to Draft (below reviewers) and adding skip-ci label, you can still see CI build result at your branch.

@OmarHawk OmarHawk changed the title Feature/entity fields default values Entity fields default values Mar 26, 2024
@OmarHawk OmarHawk force-pushed the feature/entity-fields-default-values branch from 5c0cb04 to a14ec0a Compare March 26, 2024 22:11
@OmarHawk OmarHawk force-pushed the feature/entity-fields-default-values branch 2 times, most recently from 5c2a5ad to d27816f Compare March 27, 2024 13:05
@OmarHawk OmarHawk marked this pull request as ready for review March 27, 2024 13:05
Copy link
Member

@mshima mshima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use lodash instead of custom implementation.

generators/liquibase/support/index.ts Outdated Show resolved Hide resolved
generators/liquibase/support/formatting.js Outdated Show resolved Hide resolved
generators/liquibase/generator.ts Outdated Show resolved Hide resolved
generators/liquibase/generator.ts Outdated Show resolved Hide resolved
@OmarHawk OmarHawk force-pushed the feature/entity-fields-default-values branch from 8b5f901 to 1b25acf Compare March 27, 2024 15:37
@OmarHawk
Copy link
Contributor Author

Please note I'd squash the commits to one once the whole Pull Request is alright

@OmarHawk
Copy link
Contributor Author

If there's anything "required" left, I'll continue next week.

@OmarHawk OmarHawk force-pushed the feature/entity-fields-default-values branch 3 times, most recently from 65c56aa to 4b9ead2 Compare April 2, 2024 06:48
@OmarHawk
Copy link
Contributor Author

OmarHawk commented Apr 3, 2024

If you could update your link @mshima in that one open review comment to point to something specific, I may be able to finish my Pull Request :)

@OmarHawk OmarHawk force-pushed the feature/entity-fields-default-values branch from af23a1a to af16184 Compare April 3, 2024 16:39
@DanielFran DanielFran requested a review from mshima April 5, 2024 15:50
@OmarHawk OmarHawk force-pushed the feature/entity-fields-default-values branch 2 times, most recently from a14a406 to fc1d90d Compare April 8, 2024 09:46
@OmarHawk
Copy link
Contributor Author

OmarHawk commented Apr 8, 2024

Anything else? :)

@DanielFran DanielFran requested a review from mshima April 8, 2024 13:04
@OmarHawk OmarHawk force-pushed the feature/entity-fields-default-values branch from fc1d90d to b467379 Compare April 12, 2024 13:14
generators/liquibase/support/prepare-field.js Outdated Show resolved Hide resolved
generators/liquibase/generator.ts Outdated Show resolved Hide resolved
generators/liquibase/support/prepare-field.js Outdated Show resolved Hide resolved
generators/liquibase/generator.ts Outdated Show resolved Hide resolved
generators/liquibase/support/prepare-field.js Outdated Show resolved Hide resolved
@OmarHawk OmarHawk force-pushed the feature/entity-fields-default-values branch from c73e79f to 7695814 Compare April 15, 2024 16:11
@OmarHawk
Copy link
Contributor Author

I've updated the implementation with all the suggestions, @mshima
Thanks!

@DanielFran DanielFran requested a review from mshima April 15, 2024 16:27
Comment on lines +136 to +140
if (field.columnRequired && field.liquibaseDefaultValueAttributeValue) {
this.handleCheckFailure(
`The field ${field.fieldName} in entity ${entity.name} has both columnRequired and a defaultValue, this can lead to unexpected behaviors.`,
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the check should be changed to field.columnRequired && !field.liquibaseDefaultValueAttributeValue.

Only for new fields probably in

for (const field of entity.fields ?? []) {
prepareField(entity, field, this);
prepareFieldForLiquibase(entity, field);

This can be done later if makes sense.

@mshima mshima merged commit 78c5d6d into jhipster:main Apr 15, 2024
54 checks passed
@romarioliveira25
Copy link

Any docs about how to use this new feature?

@mshima
Copy link
Member

mshima commented Apr 24, 2024

Any docs about how to use this new feature?

Not available in 8.3.0, will be available in next release.

@OmarHawk
Copy link
Contributor Author

Any docs about how to use this new feature?

Docs are yet to be written for the next release. I'll do that by end of the week.

@mraible mraible added this to the 8.4.0 milestone Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to define default value in JDL for a field
4 participants