fix: cut faker text based on field length

This commit is contained in:
Fabio Di Stasio 2021-02-14 18:25:57 +01:00
parent a176174b8d
commit 288ff4c1a1
2 changed files with 6 additions and 2 deletions

View File

@ -240,8 +240,11 @@ export default (connections) => {
else { // Faker value
let fakeValue = faker[params.row[key].group][params.row[key].method]();
if ([...TEXT, ...LONG_TEXT].includes(type))
if ([...TEXT, ...LONG_TEXT].includes(type)) {
if (params.row[key].length)
fakeValue = fakeValue.substr(0, params.row[key].length);
fakeValue = `"${sqlEscaper(fakeValue)}"`;
}
else if ([...DATE, ...DATETIME].includes(type))
fakeValue = `"${moment(fakeValue).format('YYYY-MM-DD HH:mm:ss.SSSSSS')}"`;

View File

@ -197,7 +197,8 @@ export default {
this.$emit('update:value', {
group: this.selectedGroup,
method: this.selectedMethod,
value: this.selectedValue
value: this.selectedValue,
length: this.fieldLength
});
}
}