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