Generator-jhipster: Generating an entity with a field named "account" crashes the generator

Created on 3 Aug 2020  ·  2Comments  ·  Source: jhipster/generator-jhipster

Overview of the issue

Generating an entity (either by jhipster import-jdl or jhipster entity) with a field named account crashes the generator.

Reproduce the error

Simple JDL to reproduce:

entity A {
    account String required
}
Crashes with the following error:
events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: Copying template /.../my-project/node_modules/generator-jhipster/generators/entity-server/templates/src/main/resources/config/liquibase/fake-data/table.csv.ejs failed. [TypeError: /.../my-project/node_modules/generator-jhipster/generators/entity-server/templates/src/main/resources/config/liquibase/fake-data/table.csv.ejs:19
    17|  limitations under the License.
    18| -%>
 >> 19| <%_
    20| let table = [];
    21|
    22| // Generate CSV header

this.faker.commerce.account is not a function]
    at module.exports.error (/.../my-project/node_modules/generator-jhipster/generators/generator-base.js:1590:15)
    at /.../my-project/node_modules/generator-jhipster/generators/utils.js:256:23
    at tryHandleCache (/.../my-project/node_modules/ejs/lib/ejs.js:275:14)
    at Object.exports.renderFile (/.../my-project/node_modules/ejs/lib/ejs.js:489:10)
    at Object.renderContent (/.../my-project/node_modules/generator-jhipster/generators/utils.js:252:9)
    at module.exports.template (/.../my-project/node_modules/generator-jhipster/generators/generator-base-private.js:769:23)
    at /.../my-project/node_modules/generator-jhipster/generators/generator-base.js:2040:42
    at Array.forEach (<anonymous>)
    at module.exports.writeFilesToDisk (/.../my-project/node_modules/generator-jhipster/generators/generator-base.js:2002:45)
    at module.exports.writeServerFiles (/.../my-project/node_modules/generator-jhipster/generators/entity-server/files.js:345:18)
Emitted 'error' event on Generator instance at:
    at Immediate.<anonymous> (/.../my-project/node_modules/yeoman-generator/lib/index.js:1007:20)
    at processImmediate (internal/timers.js:456:21)
    at process.topLevelDomainCallback (domain.js:137:15)
##### **JHipster Version(s)**
[email protected] /.../project
└── [email protected]

##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "project",
      "nativeLanguage": "pt-br"
    },
    "jhipsterVersion": "6.10.1",
    "applicationType": "monolith",
    "baseName": "project",
    "packageName": "project",
    "packageFolder": "project",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "embeddableLaunchScript": false,
    "useSass": true,
    "clientPackageManager": "npm",
    "clientFramework": "angularX",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "creationTimestamp": 1596455752158,
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": true,
    "nativeLanguage": "pt-br",
    "languages": ["pt-br"],
    "blueprints": []
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory


JDL entity definitions

entity A {
  account String required
}

Environment and Tools

openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.7+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.7+10, mixed mode)

git version 2.24.2 (Apple Git-127)

node: v14.3.0

npm: 6.14.6

Docker version 19.03.12, build 48a66213fe

docker-compose version 1.26.2, build eefe0d31

identical .jhipster/A.json

  • [x] Checking this box is mandatory (this is just to show you read everything)
area fake-data

Most helpful comment

According to faker.js readme, the account function should be under finance, but jhipster is calling faker.commerce.account();

Will submit a PR soon

All 2 comments

According to faker.js readme, the account function should be under finance, but jhipster is calling faker.commerce.account();

Will submit a PR soon

Thanks you @leonardortlima

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SudharakaP picture SudharakaP  ·  3Comments

DanielFran picture DanielFran  ·  3Comments

lsadehaan picture lsadehaan  ·  3Comments

marcelinobadin picture marcelinobadin  ·  3Comments

ahmedeldeeb25 picture ahmedeldeeb25  ·  3Comments