From bb86a3b8cc16cb2542abe6d3061197c6dd84c6d8 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Thu, 16 Sep 2021 13:54:09 +0200 Subject: [PATCH] fix + disabled new table for mongo --- packages/tools/src/nameTools.ts | 6 +++--- packages/web/src/commands/stdCommands.ts | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/tools/src/nameTools.ts b/packages/tools/src/nameTools.ts index 4a0256f9..03319627 100644 --- a/packages/tools/src/nameTools.ts +++ b/packages/tools/src/nameTools.ts @@ -80,15 +80,15 @@ export function fillConstraintNames(table: TableInfo, dialect: SqlDialect) { if (res.primaryKey && !res.primaryKey.constraintName && !dialect.anonymousPrimaryKey) { res.primaryKey.constraintName = `PK_${res.pureName}`; } - for (const fk of res.foreignKeys) { + for (const fk of res.foreignKeys || []) { if (fk.constraintName) continue; fk.constraintName = columnsConstraintName('FK', res, fk.columns); } - for (const ix of res.indexes) { + for (const ix of res.indexes || []) { if (ix.constraintName) continue; ix.constraintName = columnsConstraintName('IX', res, ix.columns); } - for (const uq of res.uniques) { + for (const uq of res.uniques || []) { if (uq.constraintName) continue; uq.constraintName = columnsConstraintName('UQ', res, uq.columns); } diff --git a/packages/web/src/commands/stdCommands.ts b/packages/web/src/commands/stdCommands.ts index 7b0003f3..69b18b8c 100644 --- a/packages/web/src/commands/stdCommands.ts +++ b/packages/web/src/commands/stdCommands.ts @@ -1,4 +1,4 @@ -import { currentDatabase, currentTheme, extensions, getVisibleToolbar, visibleToolbar } from '../stores'; +import { currentDatabase, currentTheme, extensions, getExtensions, getVisibleToolbar, visibleToolbar } from '../stores'; import registerCommand from './registerCommand'; import { derived, get } from 'svelte/store'; import { ThemeDefinition } from 'dbgate-types'; @@ -18,6 +18,7 @@ import { getCurrentConfig, getCurrentDatabase } from '../stores'; import './recentDatabaseSwitch'; import hasPermission from '../utility/hasPermission'; import _ from 'lodash'; +import { findEngineDriver } from 'dbgate-tools'; const electron = getElectron(); @@ -112,7 +113,10 @@ registerCommand({ name: 'Table', toolbar: true, toolbarName: 'New table', - testEnabled: () => !!get(currentDatabase), + testEnabled: () => { + const driver = findEngineDriver(get(currentDatabase)?.connection, getExtensions()); + return !!get(currentDatabase) && !driver?.dialect?.nosql; + }, onClick: () => { const $currentDatabase = get(currentDatabase); const connection = _.get($currentDatabase, 'connection') || {};