jhipster / jhipster-dotnetcore

JHipster.NET blueprint
Apache License 2.0
310 stars 92 forks source link

Unexpected behavior when updating entities with the command "jhipster import-jdl app.jh" #821

Open sergrdz opened 3 years ago

sergrdz commented 3 years ago
Overview of the issue

When the command is executed, all the entities are updated and not only the one with changes.

Reproduce the error
  1. Create a microservice type application
  2. Import a file with the command "jhipster import-jdl app.jh"
  3. Make a change to an entity
  4. Import again with the command "jhipster import-jdl app.jh"
Suggest a Fix

The database type is set incorrectly in the file ".yo-rc.json", currently when generating a microservice with sqlite the file is generated as follows:

"databaseType": "sqllite", "prodDatabaseType": "mysql", "devDatabaseType": "h2Disk",

The correct thing should I think it should be, which is how it is generated in the java generator

"databaseType": "sql", "prodDatabaseType": "mysql", "devDatabaseType": "h2Disk",

When adjusting manually, entities with changes are already detected, but all entities are still updated.

JHipster Version(s)

3.0.1

Browsers and Operating System
ivanmonteiro commented 3 years ago

Is the import-jdl behaviour different from the (java) jhipster?

Here is a quick snippet that I use as a work-around when I want to import only one entity by jdl:

jhipster import-jdl jdl.jh --json-only
jhipster entity EntityName --single-entity

About databaseType: I think this generator uses databaseType and ignores the others (prodDatabaseType and devDatabaseType) If I'm not mistaken.

sergrdz commented 3 years ago

I have a productive gateway with the Jhipster v6.10.1 version and only the affected entity is updated, I'm not sure if the behavior is maintained in the latest version.

It is correct that prodDatabaseType and devDatabaseType are ignored. I think if it is not used as in the base generator there may be incorrect behaviors, as in the case of pagination it is always set as NO_PAGINATION. And the files generated in the .jhipster folder always get a "no" in the "pagination" field, even if the definition says otherwise.

In this file you will find the validation generator-jhipster / generators / entity / index.js

if (! [SQL, MONGODB, COUCHBASE, NEO4J] .includes (context.databaseType)) { this.entityConfig.pagination = NO_PAGINATION; }

nicolas63 commented 3 years ago

@sergrdz thanks for your feedback you are right this code

if (! [SQL, MONGODB, COUCHBASE, NEO4J] .includes (context.databaseType)) {
this.entityConfig.pagination = NO_PAGINATION;
}

introduce a bug i need to investigate to resolve it. In the meantime i think the command line suggested by @ivanmonteiro can help you