If entity has no javadoc in JDL and command jhipster import-jdl is executed multiple times without changes in JDL then this entity without javadoc is regenerated each time import-jdl is executed.
Motivation for or Use Case
It confuses if import-jdl claims that there are changes but actually no changes.
And this is not optimal to regenerate if no changes.
And without changes in PR #340 this is causing generating new liquibase changelogs for every unchanged entity which has no javadoc in JDL.
Reproduce the error
Generate application with jhipster
Compose JDL where exists entities without javadoc
Import entities from JDL by jhipster import-jdl
Re-execute jhipster import-jdl without any change in JDL.
Re-executing jhipster import-jdl regenerates entities which has no javadoc in JDL.
If entity javadoc is missing in JDL then entity configuration parsed from JDL contains key javadoc with value undefined.
But in entity configuration read from disk this key javadoc is missing.
By this reason Object.keys(firstEntity).length !== Object.keys(secondEntity).length is true here: https://github.com/jhipster/jhipster-core/blob/master/lib/utils/object_utils.js#L53 and entity is counted as changed entity.
Possible fix:
add (removes keys which value is undefined before comparison):
Overview of the issue
If entity has no javadoc in JDL and command
jhipster import-jdl
is executed multiple times without changes in JDL then this entity without javadoc is regenerated each timeimport-jdl
is executed.Motivation for or Use Case
It confuses if
import-jdl
claims that there are changes but actually no changes.And this is not optimal to regenerate if no changes.
And without changes in PR #340 this is causing generating new liquibase changelogs for every unchanged entity which has no javadoc in JDL.
Reproduce the error
Generate application with
jhipster
Compose JDL where exists entities without javadoc
Import entities from JDL by
jhipster import-jdl
Re-execute
jhipster import-jdl
without any change in JDL.Re-executing
jhipster import-jdl
regenerates entities which has no javadoc in JDL.Related issues
jhipster/generator-jhipster#9837
jhipster/generator-jhipster#9996
Suggest a Fix
If entity javadoc is missing in JDL then entity configuration parsed from JDL contains key
javadoc
with valueundefined
.But in entity configuration read from disk this key
javadoc
is missing.By this reason
Object.keys(firstEntity).length !== Object.keys(secondEntity).length
istrue
here: https://github.com/jhipster/jhipster-core/blob/master/lib/utils/object_utils.js#L53 and entity is counted as changed entity.Possible fix:
add (removes keys which value is
undefined
before comparison):after this line: https://github.com/jhipster/jhipster-core/blob/master/lib/utils/object_utils.js#L47
JHipster Version(s)
JHipster configuration, a
.yo-rc.json
file generated in the root folder.yo-rc.json file
JDL for the Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryJDL entity definitions
Environment and Tools
java version "1.8.0_211" Java(TM) SE Runtime Environment (build 1.8.0_211-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
git version 2.21.0.windows.1
node: v10.15.3
npm: 6.9.0
yeoman: 2.0.6
yarn: 1.15.2
Docker version 18.09.2, build 6247962
docker-compose version 1.23.2, build 1110ad01
Browsers and Operating System
Windows 10