Generator-jhipster: Fake Data for JDL string pattern causes liquidbase error

Created on 28 Sep 2019  路  2Comments  路  Source: jhipster/generator-jhipster

Overview of the issue

For the following JDL descrpition:

The JDL String pattern(/^[^@\s]+@[^@\s]+\.[^@\s]+$/) throws liquid base error when loading fake data.

 Reason: liquibase.exception.UnexpectedLiquibaseException: CSV file config/liquibase/fake-data/centro_de_actividad.csv Line 2 has 7 values defined, Header has 5. Numbers MUST be equal (check for unquoted string with embedded commas)

The attached centro_de_actividad.txt CSV of fake data is produced, which gives the error, I believe because a ; is generated in the email field:

This is the first row of the centro_de_actividad.csv

id;nombre;telefono;nombre_de_contacto;email_de_contacto
1;New York tangible Mississippi;Frozen bus;hard drive Robust Networked;7`fPr4Ps]-8c:1DV<UDz_a>dCnD>HTw">f58Aaw(X'Xbna;J2)15v_z%AIu8d=lA%{W/R}hsJm7cP@F=?#_dVFX=tt$Ncc1+2}{*,_n|WfRcyHrI?zRPHa.Dc0JC8/c9V\DE?oeO}a}>UY
Motivation for or Use Case

I wanted to validate email, and found that regular expression on the web.

Reproduce the error

Import the following JDL

entity CentroDeActividad {
    nombre String required,
    telefono String,
    nombreDeContacto String,
    emailDeContacto String pattern(/^[^@\s]+@[^@\s]+\.[^@\s]+$/)

}
Related issues
Suggest a Fix
JHipster Version(s)

v6.2.0

JHipster configuration

Use the JDL from above

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

Use the JDL from above

Browsers and Operating System
Windows 10 / WSL
  • [x] Checking this box is mandatory (this is just to show you read everything)
$$ bug-bounty $$ $100 area good first issue fake-data

Most helpful comment

I moved the issue to the generator repository as the bug and fix will be here.

The issue is that the regex pattern generation in the fake-data/table.csv.ejs template can generate semicolons double quotes if the regex pattern allows. Double quotes are used around the generated regex string so it thinks there should be more columns. Solution is to escape the quotes.

@poolebu Until this is fixed, a simple workaround is to exclude semicolons from the email address regex.

Update: The semicolon issue is fixed in v6.3.0 but there's a different issue now.

All 2 comments

I moved the issue to the generator repository as the bug and fix will be here.

The issue is that the regex pattern generation in the fake-data/table.csv.ejs template can generate semicolons double quotes if the regex pattern allows. Double quotes are used around the generated regex string so it thinks there should be more columns. Solution is to escape the quotes.

@poolebu Until this is fixed, a simple workaround is to exclude semicolons from the email address regex.

Update: The semicolon issue is fixed in v6.3.0 but there's a different issue now.

Got it! Thank You @ruddell , I did that and it works wonders.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SudharakaP picture SudharakaP  路  3Comments

DanielFran picture DanielFran  路  3Comments

pascalgrimaud picture pascalgrimaud  路  4Comments

chegola picture chegola  路  4Comments

tomj0101 picture tomj0101  路  3Comments