jhipster / jhipster-core

JHipster Domain Language, used by JHipster UML and JDL-Studio to generate entities
Apache License 2.0
345 stars 114 forks source link

JDL Parser Error if name of enum contains string 'Blob' #470

Closed vlk32 closed 4 years ago

vlk32 commented 4 years ago
Overview of the issue

Enum containing string Blob is not allowed.

Motivation for or Use Case

I wanted to use a enum which contains string Blob. JDL parser produces incorrect error message Error: Unrecognised Blob type: TypBlobuX.. It was hard to me realise, that there is not allowed usage substring Blob as a part of the enum name.

Reproduce the error
vlk@vlk:$ cat jh.jh 
enum TypBlobuX {
    DAVKA, VYSTUP
}

entity LABlob {
    typ TypBlobuX required
        data AnyBlob required
}
vlk@vlk:$ jhipster import-jdl jh.jh
INFO! Using JHipster version installed locally in current project's node_modules
INFO! Executing import-jdl jh.jh
INFO! Options: from-cli: true, inline: 
INFO! Found .yo-rc.json on path. This is an existing app
INFO! The JDL is being parsed.
Error: Unrecognised Blob type: TypBlobuX.
Error while parsing applications and entities from the JDL Error: Unrecognised Blob type: TypBlobuX.
Error: Unrecognised Blob type: TypBlobuX.
    at getBlobFieldData (/home/vlk/work/arborai/lucus/larix/node_modules/jhipster-core/lib/converters/JDLToJSON/jdl_to_json_field_converter.js:102:13)
    at /home/vlk/work/arborai/lucus/larix/node_modules/jhipster-core/lib/converters/JDLToJSON/jdl_to_json_field_converter.js:61:29
    at Array.forEach (<anonymous>)
    at JDLEntity.forEachField (/home/vlk/work/arborai/lucus/larix/node_modules/jhipster-core/lib/core/jdl_entity.js:58:32)
    at getConvertedFieldsForEntity (/home/vlk/work/arborai/lucus/larix/node_modules/jhipster-core/lib/converters/JDLToJSON/jdl_to_json_field_converter.js:48:13)
    at /home/vlk/work/arborai/lucus/larix/node_modules/jhipster-core/lib/converters/JDLToJSON/jdl_to_json_field_converter.js:40:35
    at /home/vlk/work/arborai/lucus/larix/node_modules/jhipster-core/lib/core/jdl_object.js:140:7
    at Array.forEach (<anonymous>)
    at JDLObject.forEachEntity (/home/vlk/work/arborai/lucus/larix/node_modules/jhipster-core/lib/core/jdl_object.js:138:32)
    at Object.convert (/home/vlk/work/arborai/lucus/larix/node_modules/jhipster-core/lib/converters/JDLToJSON/jdl_to_json_field_converter.js:39:13)
Error during import-jdl: Unrecognised Blob type: TypBlobuX.
Error: Unrecognised Blob type: TypBlobuX.
    at getBlobFieldData (/home/vlk/work/arborai/lucus/larix/node_modules/jhipster-core/lib/converters/JDLToJSON/jdl_to_json_field_converter.js:102:13)
    at /home/vlk/work/arborai/lucus/larix/node_modules/jhipster-core/lib/converters/JDLToJSON/jdl_to_json_field_converter.js:61:29
    at Array.forEach (<anonymous>)
    at JDLEntity.forEachField (/home/vlk/work/arborai/lucus/larix/node_modules/jhipster-core/lib/core/jdl_entity.js:58:32)
    at getConvertedFieldsForEntity (/home/vlk/work/arborai/lucus/larix/node_modules/jhipster-core/lib/converters/JDLToJSON/jdl_to_json_field_converter.js:48:13)
    at /home/vlk/work/arborai/lucus/larix/node_modules/jhipster-core/lib/converters/JDLToJSON/jdl_to_json_field_converter.js:40:35
    at /home/vlk/work/arborai/lucus/larix/node_modules/jhipster-core/lib/core/jdl_object.js:140:7
    at Array.forEach (<anonymous>)
    at JDLObject.forEachEntity (/home/vlk/work/arborai/lucus/larix/node_modules/jhipster-core/lib/core/jdl_object.js:138:32)
    at Object.convert (/home/vlk/work/arborai/lucus/larix/node_modules/jhipster-core/lib/converters/JDLToJSON/jdl_to_json_field_converter.js:39:13)
JHipster Version(s)
larix@0.0.1-SNAPSHOT 
├── generator-jhipster@6.9.0 
├─┬ generator-jhipster-administration-database@1.0.4
│ └── generator-jhipster@6.9.0  deduped
├─┬ generator-jhipster-database-backup@1.0.7
│ └── generator-jhipster@6.9.0  deduped
└─┬ generator-jhipster-standalone-profile@2.3.0
  └── generator-jhipster@6.9.0  deduped
JHipster configuration, a .yo-rc.json file generated in the root folder
<details>
<summary>.yo-rc.json file</summary>
<pre>
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "sk.arborai.lucus.larix"
    },
    "jhipsterVersion": "6.9.0",
    "applicationType": "monolith",
    "baseName": "larix",
    "packageName": "sk.arborai.lucus.larix",
    "packageFolder": "sk/arborai/lucus/larix",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": "spring-websocket",
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "postgresql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "gradle",
    "enableSwaggerCodegen": true,
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "embeddableLaunchScript": false,
    "useSass": true,
    "clientPackageManager": "npm",
    "clientFramework": "angularX",
    "clientTheme": "spacelab",
    "clientThemeVariant": "dark",
    "creationTimestamp": 1590658222585,
    "testFrameworks": ["cucumber", "protractor"],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [
      {
        "name": "generator-jhipster-standalone-profile",
        "version": "2.3.0"
      },
      {
        "name": "generator-jhipster-administration-database",
        "version": "1.0.4"
      },
      {
        "name": "generator-jhipster-database-backup",
        "version": "1.0.7"
      }
    ],
    "enableTranslation": true,
    "blueprints": [],
    "languages": ["en", "sk"]
  }
}

</pre>
</details>
Environment and Tools

openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1~18.04-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

git version 2.17.1

node: v12.17.0

npm: 6.14.5

yeoman: 3.1.1

Docker version 19.03.10, build 9424aeaee9

docker-compose version 1.17.1, build unknown

##### **Browsers and Operating System**
Ubuntu Linux 18LTS
MathieuAA commented 4 years ago

Thanks for reporting it, I'm fixing it