mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 01:33:59 +00:00
more data types in table editor #285
This commit is contained in:
2
packages/types/dialect.d.ts
vendored
2
packages/types/dialect.d.ts
vendored
@@ -32,4 +32,6 @@ export interface SqlDialect {
|
|||||||
|
|
||||||
dropReferencesWhenDropTable?: boolean;
|
dropReferencesWhenDropTable?: boolean;
|
||||||
disableExplicitTransaction?: boolean;
|
disableExplicitTransaction?: boolean;
|
||||||
|
|
||||||
|
predefinedDataTypes: string[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
>
|
>
|
||||||
|
|
||||||
<FormTextField name="columnName" label="Column name" focused />
|
<FormTextField name="columnName" label="Column name" focused />
|
||||||
<DataTypeEditor />
|
<DataTypeEditor dialect={driver?.dialect} />
|
||||||
|
|
||||||
<FormCheckboxField name="notNull" label="NOT NULL" />
|
<FormCheckboxField name="notNull" label="NOT NULL" />
|
||||||
<FormCheckboxField name="isPrimaryKey" label="Is Primary Key" />
|
<FormCheckboxField name="isPrimaryKey" label="Is Primary Key" />
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
const { values, setFieldValue } = getFormContext();
|
const { values, setFieldValue } = getFormContext();
|
||||||
|
|
||||||
$: dataTypes = ['int', 'nvarchar(250)', 'datetime', 'numeric(10,2)', 'float'];
|
$: dataTypes = dialect?.predefinedDataTypes || ['int', 'varchar(250)', 'datetime', 'numeric(10,2)', 'float'];
|
||||||
|
|
||||||
function createDataTypesMenu() {
|
function createDataTypesMenu() {
|
||||||
return dataTypes.map(type => ({
|
return dataTypes.map(type => ({
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export let dialect;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<FormDropDownTextField name="dataType" label="Data type" menu={createDataTypesMenu} />
|
<FormDropDownTextField name="dataType" label="Data type" menu={createDataTypesMenu} />
|
||||||
|
|||||||
@@ -40,6 +40,36 @@ const dialect = {
|
|||||||
isSparse: true,
|
isSparse: true,
|
||||||
isPersisted: true,
|
isPersisted: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
predefinedDataTypes: [
|
||||||
|
'bigint',
|
||||||
|
'bit',
|
||||||
|
'decimal(10,2)',
|
||||||
|
'int',
|
||||||
|
'money',
|
||||||
|
'numeric',
|
||||||
|
'smallint',
|
||||||
|
'smallmoney',
|
||||||
|
'tinyint',
|
||||||
|
'float',
|
||||||
|
'real',
|
||||||
|
'date',
|
||||||
|
'datetime2',
|
||||||
|
'datetime',
|
||||||
|
'datetimeofffset',
|
||||||
|
'smalldatetime',
|
||||||
|
'time',
|
||||||
|
'char(20)',
|
||||||
|
'varchar(250)',
|
||||||
|
'text',
|
||||||
|
'nchar(20)',
|
||||||
|
'nvarchar(250)',
|
||||||
|
'ntext',
|
||||||
|
'binary(100)',
|
||||||
|
'varbinary(100)',
|
||||||
|
'image',
|
||||||
|
'xml',
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @type {import('dbgate-types').EngineDriver} */
|
/** @type {import('dbgate-types').EngineDriver} */
|
||||||
|
|||||||
@@ -36,6 +36,38 @@ const dialect = {
|
|||||||
isUnsigned: true,
|
isUnsigned: true,
|
||||||
isZerofill: true,
|
isZerofill: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
predefinedDataTypes: [
|
||||||
|
'char(20)',
|
||||||
|
'varchar(250)',
|
||||||
|
'binary(250)',
|
||||||
|
'varbinary(250)',
|
||||||
|
'tinyblob',
|
||||||
|
'tinytext',
|
||||||
|
'text(1000)',
|
||||||
|
'blob(1000)',
|
||||||
|
'mediumtext',
|
||||||
|
'mediumblob',
|
||||||
|
'longtext',
|
||||||
|
'longblob',
|
||||||
|
'enum(val1,val2,val3)',
|
||||||
|
'set(val1,val2,val3)',
|
||||||
|
'bit(32)',
|
||||||
|
'tinyint',
|
||||||
|
'bool',
|
||||||
|
'smallint',
|
||||||
|
'mediumint',
|
||||||
|
'int',
|
||||||
|
'bigint',
|
||||||
|
'float',
|
||||||
|
'double',
|
||||||
|
'decimal',
|
||||||
|
'date',
|
||||||
|
'datetime',
|
||||||
|
'timestamp',
|
||||||
|
'time',
|
||||||
|
'year',
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const mysqlDriverBase = {
|
const mysqlDriverBase = {
|
||||||
|
|||||||
@@ -32,6 +32,52 @@ const dialect = {
|
|||||||
dropCheck: true,
|
dropCheck: true,
|
||||||
|
|
||||||
dropReferencesWhenDropTable: true,
|
dropReferencesWhenDropTable: true,
|
||||||
|
|
||||||
|
predefinedDataTypes: [
|
||||||
|
'bigint',
|
||||||
|
'bigserial',
|
||||||
|
'bit',
|
||||||
|
'varbit',
|
||||||
|
'boolean',
|
||||||
|
'box',
|
||||||
|
'bytea',
|
||||||
|
'char(20)',
|
||||||
|
'varchar(250)',
|
||||||
|
'cidr',
|
||||||
|
'circle',
|
||||||
|
'date',
|
||||||
|
'double precision',
|
||||||
|
'inet',
|
||||||
|
'int',
|
||||||
|
'interval',
|
||||||
|
'json',
|
||||||
|
'jsonb',
|
||||||
|
'line',
|
||||||
|
'lseg',
|
||||||
|
'macaddr',
|
||||||
|
'macaddr8',
|
||||||
|
'money',
|
||||||
|
'numeric(10,2)',
|
||||||
|
'path',
|
||||||
|
'pg_lsn',
|
||||||
|
'pg_snapshot',
|
||||||
|
'point',
|
||||||
|
'polygon',
|
||||||
|
'real',
|
||||||
|
'smallint',
|
||||||
|
'smallserial',
|
||||||
|
'serial',
|
||||||
|
'text',
|
||||||
|
'time',
|
||||||
|
'timetz',
|
||||||
|
'timestamp',
|
||||||
|
'timestamptz',
|
||||||
|
'tsquery',
|
||||||
|
'tsvector',
|
||||||
|
'txid_snapshot',
|
||||||
|
'uuid',
|
||||||
|
'xml',
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const postgresDriverBase = {
|
const postgresDriverBase = {
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ const driver = {
|
|||||||
getQuerySplitterOptions: (usage) => (usage == 'stream' ? noSplitSplitterOptions : sqliteSplitterOptions),
|
getQuerySplitterOptions: (usage) => (usage == 'stream' ? noSplitSplitterOptions : sqliteSplitterOptions),
|
||||||
// isFileDatabase: true,
|
// isFileDatabase: true,
|
||||||
isElectronOnly: true,
|
isElectronOnly: true,
|
||||||
|
|
||||||
|
predefinedDataTypes: ['integer', 'real', 'text', 'blob'],
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = driver;
|
module.exports = driver;
|
||||||
|
|||||||
Reference in New Issue
Block a user