-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Values generated by Faker are changing on regeneration #14549
Comments
@kaidohallik can you try calling resetFakerSeed after it was created? generator-jhipster/utils/entity.js Line 86 in 3142b03
|
@mshima If calling |
Thinking about this, we can replace the others call, with
before generator-jhipster/generators/utils.js Line 286 in f35cf8b
With this change, files will be reproducible independently. An additional call to the faker at any file will not change others files. |
Adding Calling generator-jhipster/utils/field.js Line 276 in d2a00cd
So for related entity this is in related entity context. I'll do PR which adds call to |
I created #14595 for fix. If I tried to remove
So I added only one line for fix. |
I will take a look at #14549 (comment) later. |
Overview of the issue
In Angular entity update test
generator-jhipster/generators/entity-client/templates/angular/src/main/webapp/app/entities/update/entity-management-update.component.spec.ts.ejs
Line 84 in 943fd87
If for the related entity is not yet called
resetFakerSeed()
generator-jhipster/generators/entity-client/files.js
Line 442 in 943fd87
The same values are generated in those cases:
resetFakerSeed()
is already called for every entity and always the same value is generatedBut if neither of the above conditions is met then every regeneration generates the different values.
Entities generation order is calculated based on entity
changelogDate
:generator-jhipster/generators/generator-base.js
Lines 1559 to 1561 in 943fd87
The same problem may occur elsewhere where in entities is used Faker data for related entities.
Motivation for or Use Case
Regeneration should generate the same content as initial generation.
Reproduce the error
Generate application with:
jhipster --skip-server
Create
entities.jdl
with content:Generate first entity with:
jhipster import-jdl entities.jdl
Change
entities.jdl
to:Run again:
jhipster import-jdl entities.jdl
If now regenerating entities for example with:
then every time new random
Entity2
id-s are generated becauseEntity1
is generated beforeEntity2
andresetFakerSeed()
forEntity2
is not called yet.Related issues
Suggest a Fix
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
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.8+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.8+10, mixed mode)
git version 2.31.1.windows.1
node: v14.16.0
npm: 7.7.6
Docker version 20.10.5, build 55c4c88
docker-compose version 1.28.5, build c4eb3a1f
Browsers and Operating System
Windows 10
The text was updated successfully, but these errors were encountered: