Skip to content

Commit

Permalink
fix: issue with ENUM and SET fields on table filler modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed May 13, 2021
1 parent 7a62131 commit 475397c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/libs/clients/MySQLClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ export class MySQLClient extends AntaresCore {
remappedFields = remappedFields.map(field => {
const detailedField = response.find(f => f.name === field.name);
if (detailedField && field.orgTable === paramObj.table && field.schema === paramObj.schema)
field = { ...detailedField, ...field };
field = { ...field, ...detailedField };
return field;
});
}
Expand Down
28 changes: 25 additions & 3 deletions src/renderer/components/FakerSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@
:type="inputProps().type"
:disabled="!isChecked"
>
<select
v-else-if="enumArray"
v-model="selectedValue"
class="form-select"
:disabled="!isChecked"
@change="onChange"
>
<option
v-for="val in enumArray"
:key="val"
:value="val"
>
{{ val }}
</option>
</select>
<input
v-else
ref="formInput"
Expand Down Expand Up @@ -121,7 +136,8 @@ export default {
selectedMethod: '',
selectedValue: '',
debounceTimeout: null,
methodParams: {}
methodParams: {},
enumArray: null
};
},
computed: {
Expand Down Expand Up @@ -150,8 +166,14 @@ export default {
},
watch: {
fieldObj () {
if (this.fieldObj)
this.selectedValue = this.fieldObj.value;
if (this.fieldObj) {
if (Array.isArray(this.fieldObj.value)) {
this.enumArray = this.fieldObj.value;
this.selectedValue = this.fieldObj.value[0];
}
else
this.selectedValue = this.fieldObj.value;
}
},
selectedGroup () {
if (this.fakerMethods.length)
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/components/ModalFakerRows.vue
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ export default {
fieldDefault = moment().format(`YYYY-MM-DD HH:mm:ss${datePrecision}`);
}
}
if (field.enumValues)
fieldDefault = field.enumValues.replaceAll('\'', '').split(',');
}
rowObj[field.name] = { value: fieldDefault };
Expand Down

0 comments on commit 475397c

Please sign in to comment.