From 8da022487650039b7f34a9c86a7bd9045eba65e2 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Thu, 9 Dec 2021 18:26:59 +0100 Subject: [PATCH] fix(MySQL): wrong datetime fields default in table filler in some cases --- src/main/libs/clients/MySQLClient.js | 2 +- src/renderer/components/ModalFakerRows.vue | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/libs/clients/MySQLClient.js b/src/main/libs/clients/MySQLClient.js index be987c32..4a8cbf1f 100644 --- a/src/main/libs/clients/MySQLClient.js +++ b/src/main/libs/clients/MySQLClient.js @@ -441,7 +441,7 @@ export class MySQLClient extends AntaresCore { collation: field.COLLATION_NAME, autoIncrement: field.EXTRA.includes('auto_increment'), onUpdate: field.EXTRA.toLowerCase().includes('on update') - ? field.EXTRA.substr(field.EXTRA.indexOf('on update') + 9, field.EXTRA.length) + ? field.EXTRA.substr(field.EXTRA.indexOf('on update') + 9, field.EXTRA.length).trim() : '', comment: field.COLUMN_COMMENT }; diff --git a/src/renderer/components/ModalFakerRows.vue b/src/renderer/components/ModalFakerRows.vue index e12dbaff..829d5eac 100644 --- a/src/renderer/components/ModalFakerRows.vue +++ b/src/renderer/components/ModalFakerRows.vue @@ -41,7 +41,7 @@ @@ -264,7 +264,7 @@ export default { else if (BIT.includes(field.type)) fieldDefault = field.default.replaceAll('\'', '').replaceAll('b', ''); else if (DATETIME.includes(field.type)) { - if (field.default && ['current_timestamp', 'now()'].includes(field.default.toLowerCase())) { + if (field.default && ['current_timestamp', 'now()'].some(term => field.default.toLowerCase().includes(term))) { let datePrecision = ''; for (let i = 0; i < field.datePrecision; i++) datePrecision += i === 0 ? '.S' : 'S'; @@ -281,7 +281,7 @@ export default { rowObj[field.name] = { value: fieldDefault }; - if (field.autoIncrement)// Disable by default auto increment fields + if (field.autoIncrement || !!field.onUpdate)// Disable by default auto increment or "on update" fields this.fieldsToExclude = [...this.fieldsToExclude, field.name]; }