clickhouse: added specifcNotNull dialect option

This commit is contained in:
Jan Prochazka
2024-09-11 15:41:26 +02:00
parent fb39cd1302
commit f74533b42f
11 changed files with 17 additions and 9 deletions

View File

@@ -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()) {

View File

@@ -49,6 +49,7 @@ export interface ColumnInfo extends NamedObjectInfo {
notNull?: boolean;
autoIncrement?: boolean;
dataType: string;
displayedDataType?: string;
precision?: number;
scale?: number;
length?: number;

View File

@@ -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;

View File

@@ -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) },
];
}

View File

@@ -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>

View File

@@ -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}

View File

@@ -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>

View File

@@ -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

View File

@@ -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,

View File

@@ -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,
};
}

View File

@@ -64,6 +64,7 @@ const dialect = {
dropIndex: true,
anonymousPrimaryKey: true,
createColumnWithColumnKeyword: true,
specificNotNull: true,
columnProperties: {
columnComment: true,