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

Field annotations with falsy values are not correctly handled #28751

Closed
3 tasks done
francesco-carusi-zupit opened this issue Feb 20, 2025 · 0 comments · Fixed by #28753
Closed
3 tasks done

Field annotations with falsy values are not correctly handled #28751

francesco-carusi-zupit opened this issue Feb 20, 2025 · 0 comments · Fixed by #28753

Comments

@francesco-carusi-zupit
Copy link
Contributor

Overview of the issue

annotating an entity field with falsy values, like:
@isEnabled(false)
creates the following field options object:
field.options == { isEnabled: true }

JHipster JDL
JDL definitions
entity SampleEntity {
  @isEnabled(false)
  @isOpen(0)
  @isHappy("")
  sampleField String
}
  
  • JDL is mandatory for bug reports. This will allow us to use automated tests and genarate the broken sample using jhipster from-issue command.
Motivation for or Use Case

I'm writing a custom generator that uses entities from a JDL file.

Reproduce the error

create a JDL file with an entity and annotate a field with falsy values, e.g.:

entity SampleEntity {
  @isEnabled(false)
  @isOpen(0)
  @isHappy("")
  sampleField String
}

run the JDL parser, you'll end up with a parsed entity config like:

{
  "applications": "*",
  "fields": [
    {
      "fieldName": "sampleField",
      "fieldType": "String",
      "options": {
        "isEnabled": true,
        "isHappy": true,
        "isOpen": true
      }
    }
  ],
  "name": "SampleEntity",
  "relationships": []
}
Related issues

I think that issue #28312 may be related to this problem

Suggest a Fix

I'll open a pull request with a fix

JHipster Version(s)

8.9.0

Browsers and Operating System

Windows

  • Tickets opened without reproduction steps or that doesn't follows the template recommendation will be closed.
  • Checking this box is mandatory (this is just to show you read everything)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant