hide indexes from clickhouse

This commit is contained in:
Jan Prochazka
2024-09-12 13:20:15 +02:00
parent 2f1cbbd75e
commit d2e49967e4
4 changed files with 50 additions and 42 deletions

View File

@@ -37,6 +37,7 @@ export interface SqlDialect {
specificNullabilityImplementation?: boolean; specificNullabilityImplementation?: boolean;
omitForeignKeys?: boolean; omitForeignKeys?: boolean;
omitUniqueConstraints?: boolean; omitUniqueConstraints?: boolean;
omitIndexes?: boolean;
sortingKeys?: boolean; sortingKeys?: boolean;
// syntax for create column: ALTER TABLE table ADD COLUMN column // syntax for create column: ALTER TABLE table ADD COLUMN column

View File

@@ -30,7 +30,7 @@
icon: 'icon add-key', icon: 'icon add-key',
toolbar: true, toolbar: true,
isRelatedToTab: true, isRelatedToTab: true,
testEnabled: () => getCurrentEditor()?.getIsWritable(), testEnabled: () => getCurrentEditor()?.getIsWritable() && !getCurrentEditor()?.getDialect()?.omitForeignKeys,
onClick: () => getCurrentEditor().addForeignKey(), onClick: () => getCurrentEditor().addForeignKey(),
}); });
@@ -41,7 +41,7 @@
icon: 'icon add-key', icon: 'icon add-key',
toolbar: true, toolbar: true,
isRelatedToTab: true, isRelatedToTab: true,
testEnabled: () => getCurrentEditor()?.getIsWritable(), testEnabled: () => getCurrentEditor()?.getIsWritable() && !getCurrentEditor()?.getDialect()?.omitIndexes,
onClick: () => getCurrentEditor().addIndex(), onClick: () => getCurrentEditor().addIndex(),
}); });
@@ -52,7 +52,7 @@
icon: 'icon add-key', icon: 'icon add-key',
toolbar: true, toolbar: true,
isRelatedToTab: true, isRelatedToTab: true,
testEnabled: () => getCurrentEditor()?.getIsWritable(), testEnabled: () => getCurrentEditor()?.getIsWritable() && !getCurrentEditor()?.getDialect()?.omitUniqueConstraints,
onClick: () => getCurrentEditor().addUnique(), onClick: () => getCurrentEditor().addUnique(),
}); });
</script> </script>
@@ -98,6 +98,10 @@
return isWritable; return isWritable;
} }
export function getDialect() {
return driver?.dialect;
}
export function addColumn() { export function addColumn() {
showModal(ColumnEditorModal, { showModal(ColumnEditorModal, {
setTableInfo, setTableInfo,
@@ -275,45 +279,47 @@
/> />
{/if} {/if}
<ObjectListControl {#if !driver?.dialect?.omitIndexes}
collection={indexes} <ObjectListControl
onAddNew={isWritable && columns?.length > 0 ? addIndex : null} collection={indexes}
title={`Indexes (${indexes?.length || 0})`} onAddNew={isWritable && columns?.length > 0 ? addIndex : null}
emptyMessage={isWritable ? 'No index defined' : null} title={`Indexes (${indexes?.length || 0})`}
clickable emptyMessage={isWritable ? 'No index defined' : null}
on:clickrow={e => showModal(IndexEditorModal, { constraintInfo: e.detail, tableInfo, setTableInfo })} clickable
columns={[ on:clickrow={e => showModal(IndexEditorModal, { constraintInfo: e.detail, tableInfo, setTableInfo })}
{ columns={[
fieldName: 'columns', {
header: 'Columns', fieldName: 'columns',
slot: 0, header: 'Columns',
}, slot: 0,
{ },
fieldName: 'unique', {
header: 'Unique', fieldName: 'unique',
slot: 1, header: 'Unique',
}, slot: 1,
isWritable },
? { isWritable
fieldName: 'actions', ? {
sortable: true, fieldName: 'actions',
slot: 2, sortable: true,
} slot: 2,
: null, }
]} : null,
> ]}
<svelte:fragment slot="name" let:row><ConstraintLabel {...row} /></svelte:fragment>
<svelte:fragment slot="0" let:row>{row?.columns.map(x => x.columnName).join(', ')}</svelte:fragment>
<svelte:fragment slot="1" let:row>{row?.isUnique ? 'YES' : 'NO'}</svelte:fragment>
<svelte:fragment slot="2" let:row
><Link
onClick={e => {
e.stopPropagation();
setTableInfo(tbl => editorDeleteConstraint(tbl, row));
}}>Remove</Link
></svelte:fragment
> >
</ObjectListControl> <svelte:fragment slot="name" let:row><ConstraintLabel {...row} /></svelte:fragment>
<svelte:fragment slot="0" let:row>{row?.columns.map(x => x.columnName).join(', ')}</svelte:fragment>
<svelte:fragment slot="1" let:row>{row?.isUnique ? 'YES' : 'NO'}</svelte:fragment>
<svelte:fragment slot="2" let:row
><Link
onClick={e => {
e.stopPropagation();
setTableInfo(tbl => editorDeleteConstraint(tbl, row));
}}>Remove</Link
></svelte:fragment
>
</ObjectListControl>
{/if}
{#if !driver?.dialect?.omitUniqueConstraints} {#if !driver?.dialect?.omitUniqueConstraints}
<ObjectListControl <ObjectListControl

View File

@@ -194,7 +194,7 @@
<ToolStripCommandButton command="tableStructure.save" /> <ToolStripCommandButton command="tableStructure.save" />
<ToolStripCommandButton command="tableStructure.reset" /> <ToolStripCommandButton command="tableStructure.reset" />
<ToolStripCommandButton command="tableEditor.addColumn" /> <ToolStripCommandButton command="tableEditor.addColumn" />
<ToolStripCommandButton command="tableEditor.addIndex" /> <ToolStripCommandButton command="tableEditor.addIndex" hideDisabled />
{#if objectTypeField == 'tables'} {#if objectTypeField == 'tables'}
<ToolStripButton <ToolStripButton

View File

@@ -102,6 +102,7 @@ const dialect = {
specificNullabilityImplementation: true, specificNullabilityImplementation: true,
omitForeignKeys: true, omitForeignKeys: true,
omitUniqueConstraints: true, omitUniqueConstraints: true,
omitIndexes: true,
sortingKeys: true, sortingKeys: true,
columnProperties: { columnProperties: {