mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 15:03:57 +00:00
clickhouse: added specifcNotNull dialect option
This commit is contained in:
@@ -246,7 +246,7 @@ export class SqlDumper implements AlterProcessor {
|
|||||||
|
|
||||||
this.putRaw(' ');
|
this.putRaw(' ');
|
||||||
this.specialColumnOptions(column);
|
this.specialColumnOptions(column);
|
||||||
if (includeNullable) {
|
if (includeNullable && !this.dialect?.specificNotNull) {
|
||||||
this.put(column.notNull ? '^not ^null' : '^null');
|
this.put(column.notNull ? '^not ^null' : '^null');
|
||||||
}
|
}
|
||||||
if (includeDefault && column.defaultValue?.trim()) {
|
if (includeDefault && column.defaultValue?.trim()) {
|
||||||
|
|||||||
1
packages/types/dbinfo.d.ts
vendored
1
packages/types/dbinfo.d.ts
vendored
@@ -49,6 +49,7 @@ export interface ColumnInfo extends NamedObjectInfo {
|
|||||||
notNull?: boolean;
|
notNull?: boolean;
|
||||||
autoIncrement?: boolean;
|
autoIncrement?: boolean;
|
||||||
dataType: string;
|
dataType: string;
|
||||||
|
displayedDataType?: string;
|
||||||
precision?: number;
|
precision?: number;
|
||||||
scale?: number;
|
scale?: number;
|
||||||
length?: number;
|
length?: number;
|
||||||
|
|||||||
2
packages/types/dialect.d.ts
vendored
2
packages/types/dialect.d.ts
vendored
@@ -34,6 +34,8 @@ export interface SqlDialect {
|
|||||||
createCheck?: boolean;
|
createCheck?: boolean;
|
||||||
dropCheck?: boolean;
|
dropCheck?: boolean;
|
||||||
|
|
||||||
|
specificNotNull?: boolean;
|
||||||
|
|
||||||
// syntax for create column: ALTER TABLE table ADD COLUMN column
|
// syntax for create column: ALTER TABLE table ADD COLUMN column
|
||||||
createColumnWithColumnKeyword?: boolean;
|
createColumnWithColumnKeyword?: boolean;
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
return [
|
return [
|
||||||
{ text: 'Rename column', onClick: handleRenameColumn },
|
{ text: 'Rename column', onClick: handleRenameColumn },
|
||||||
{ text: 'Drop column', onClick: handleDropColumn },
|
{ text: 'Drop column', onClick: handleDropColumn },
|
||||||
{ text: 'Copy name', onClick: () => navigator.clipboard.writeText(data.columnName)},
|
{ text: 'Copy name', onClick: () => navigator.clipboard.writeText(data.columnName) },
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,9 +88,9 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<ColumnLabel {...column} />
|
<ColumnLabel {...column} />
|
||||||
|
|
||||||
{#if _.isString(column.dataType) && !order}
|
{#if _.isString(column.displayedDataType || column.dataType) && !order}
|
||||||
<span class="data-type" title={column.dataType}>
|
<span class="data-type" title={column.dataType}>
|
||||||
{column.dataType.toLowerCase()}
|
{(column.displayedDataType || column.dataType).toLowerCase()}
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -196,7 +196,7 @@
|
|||||||
<div class="space" />
|
<div class="space" />
|
||||||
{#if designer?.style?.showDataType && column?.dataType}
|
{#if designer?.style?.showDataType && column?.dataType}
|
||||||
<div class="ml-2">
|
<div class="ml-2">
|
||||||
{column?.dataType.toLowerCase()}
|
{(column?.displayedDataType || column?.dataType).toLowerCase()}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if designer?.style?.showNullability}
|
{#if designer?.style?.showNullability}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
export let columnName = '';
|
export let columnName = '';
|
||||||
export let extInfo = null;
|
export let extInfo = null;
|
||||||
export let dataType = null;
|
export let dataType = null;
|
||||||
|
export let displayedDataType = null;
|
||||||
export let showDataType = false;
|
export let showDataType = false;
|
||||||
export let foreignKey;
|
export let foreignKey;
|
||||||
export let conid = undefined;
|
export let conid = undefined;
|
||||||
@@ -59,7 +60,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
{:else if dataType}
|
{:else if dataType}
|
||||||
<span class="extinfo">{dataType.toLowerCase()}</span>
|
<span class="extinfo">{(displayedDataType || dataType).toLowerCase()}</span>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -32,7 +32,9 @@
|
|||||||
<FormTextField name="columnName" label="Column name" focused disabled={isReadOnly} />
|
<FormTextField name="columnName" label="Column name" focused disabled={isReadOnly} />
|
||||||
<DataTypeEditor dialect={driver?.dialect} disabled={isReadOnly} />
|
<DataTypeEditor dialect={driver?.dialect} disabled={isReadOnly} />
|
||||||
|
|
||||||
|
{#if !driver?.dialect?.specificNotNull}
|
||||||
<FormCheckboxField name="notNull" label="NOT NULL" disabled={isReadOnly} />
|
<FormCheckboxField name="notNull" label="NOT NULL" disabled={isReadOnly} />
|
||||||
|
{/if}
|
||||||
<FormCheckboxField name="isPrimaryKey" label="Is Primary Key" disabled={isReadOnly} />
|
<FormCheckboxField name="isPrimaryKey" label="Is Primary Key" disabled={isReadOnly} />
|
||||||
<FormCheckboxField name="autoIncrement" label="Is Autoincrement" disabled={isReadOnly} />
|
<FormCheckboxField name="autoIncrement" label="Is Autoincrement" disabled={isReadOnly} />
|
||||||
<FormTextField
|
<FormTextField
|
||||||
|
|||||||
@@ -187,7 +187,7 @@
|
|||||||
on:clickrow={e => showModal(ColumnEditorModal, { columnInfo: e.detail, tableInfo, setTableInfo, driver })}
|
on:clickrow={e => showModal(ColumnEditorModal, { columnInfo: e.detail, tableInfo, setTableInfo, driver })}
|
||||||
onAddNew={isWritable ? addColumn : null}
|
onAddNew={isWritable ? addColumn : null}
|
||||||
columns={[
|
columns={[
|
||||||
{
|
!driver?.dialect?.specificNotNull && {
|
||||||
fieldName: 'notNull',
|
fieldName: 'notNull',
|
||||||
header: 'Nullability',
|
header: 'Nullability',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ const sql = require('./sql');
|
|||||||
function extractDataType(dataType) {
|
function extractDataType(dataType) {
|
||||||
if (!dataType) return {};
|
if (!dataType) return {};
|
||||||
if (dataType.startsWith('Nullable(')) {
|
if (dataType.startsWith('Nullable(')) {
|
||||||
dataType = dataType.substring('Nullable('.length, dataType.length - 1);
|
const displayedDataType = dataType.substring('Nullable('.length, dataType.length - 1);
|
||||||
return {
|
return {
|
||||||
dataType,
|
dataType,
|
||||||
|
displayedDataType,
|
||||||
notNull: false,
|
notNull: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ const dialect = {
|
|||||||
dropIndex: true,
|
dropIndex: true,
|
||||||
anonymousPrimaryKey: true,
|
anonymousPrimaryKey: true,
|
||||||
createColumnWithColumnKeyword: true,
|
createColumnWithColumnKeyword: true,
|
||||||
|
specificNotNull: true,
|
||||||
|
|
||||||
columnProperties: {
|
columnProperties: {
|
||||||
columnComment: true,
|
columnComment: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user