From 04804b07c71cec271c31ace13bd41b2c7415e892 Mon Sep 17 00:00:00 2001 From: Fabio Date: Sat, 17 Oct 2020 10:12:40 +0200 Subject: [PATCH] feat(render): field type and length on table header mouse hover --- src/main/libs/clients/MySQLClient.js | 9 ++++++++- src/renderer/components/ModalNewTableRow.vue | 2 +- src/renderer/components/Workspace.vue | 3 ++- src/renderer/components/WorkspaceQueryTab.vue | 8 ++++++-- src/renderer/components/WorkspaceQueryTable.vue | 13 ++++++++++++- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/main/libs/clients/MySQLClient.js b/src/main/libs/clients/MySQLClient.js index fba1a746..19f5bffd 100644 --- a/src/main/libs/clients/MySQLClient.js +++ b/src/main/libs/clients/MySQLClient.js @@ -171,6 +171,9 @@ export class MySQLClient extends AntaresCore { .run(); return rows.map(field => { + let numLength = field.COLUMN_TYPE.match(/int\(([^)]+)\)/); + numLength = numLength ? +numLength.pop() : null; + return { name: field.COLUMN_NAME, key: field.COLUMN_KEY.toLowerCase(), @@ -178,9 +181,13 @@ export class MySQLClient extends AntaresCore { schema: field.TABLE_SCHEMA, table: field.TABLE_NAME, numPrecision: field.NUMERIC_PRECISION, + numLength, datePrecision: field.DATETIME_PRECISION, charLength: field.CHARACTER_MAXIMUM_LENGTH, - isNullable: field.IS_NULLABLE, + nullable: field.IS_NULLABLE.includes('YES'), + unsigned: field.COLUMN_TYPE.includes('unsigned'), + zerofill: field.COLUMN_TYPE.includes('zerofill'), + order: field.ORDINAL_POSITION, default: field.COLUMN_DEFAULT, charset: field.CHARACTER_SET_NAME, collation: field.COLLATION_NAME, diff --git a/src/renderer/components/ModalNewTableRow.vue b/src/renderer/components/ModalNewTableRow.vue index abec7864..2d716030 100644 --- a/src/renderer/components/ModalNewTableRow.vue +++ b/src/renderer/components/ModalNewTableRow.vue @@ -248,7 +248,7 @@ export default { }, fieldLength (field) { if ([...BLOB, ...LONG_TEXT].includes(field.type)) return null; - return field.numPrecision || field.datePrecision || field.charLength || 0; + return field.numLength || field.datePrecision || field.charLength || 0; }, inputProps (field) { if ([...TEXT, ...LONG_TEXT].includes(field.type)) diff --git a/src/renderer/components/Workspace.vue b/src/renderer/components/Workspace.vue index aab41f0d..fb206e78 100644 --- a/src/renderer/components/Workspace.vue +++ b/src/renderer/components/Workspace.vue @@ -33,7 +33,8 @@ @click="selectTab({uid: workspace.uid, tab: tab.uid})" @mousedown.middle="closeTab(tab.uid)" > - + + Query #{{ tab.index }} {{ $t('message.affectedRows') }}: {{ affectedCount }} -
- {{ $t('word.schema') }}: {{ workspace.breadcrumbs.schema }} +
+ {{ workspace.breadcrumbs.schema }}
diff --git a/src/renderer/components/WorkspaceQueryTable.vue b/src/renderer/components/WorkspaceQueryTable.vue index 9dfc4f7b..392ec84a 100644 --- a/src/renderer/components/WorkspaceQueryTable.vue +++ b/src/renderer/components/WorkspaceQueryTable.vue @@ -39,7 +39,7 @@ :class="`key-${field.key}`" :title="keyName(field.key)" /> - {{ field.alias || field.name }} + {{ field.alias || field.name }} import { uidGen } from 'common/libs/uidGen'; +import { LONG_TEXT, BLOB } from 'common/fieldTypes'; import BaseVirtualScroll from '@/components/BaseVirtualScroll'; import WorkspaceQueryTableRow from '@/components/WorkspaceQueryTableRow'; import TableContext from '@/components/WorkspaceQueryTableContext'; @@ -92,6 +93,12 @@ export default { WorkspaceQueryTableRow, TableContext }, + filters: { + wrapNumber (num) { + if (!num) return ''; + return `(${num})`; + } + }, props: { results: Array, tabUid: [String, Number], @@ -193,6 +200,10 @@ export default { return length; }, + fieldLength (field) { + if ([...BLOB, ...LONG_TEXT].includes(field.type)) return null; + return field.numLength || field.datePrecision || field.charLength || 0; + }, keyName (key) { switch (key) { case 'pri':