mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 00:56:02 +00:00
clickhouse: nullable types
This commit is contained in:
@@ -1,6 +1,21 @@
|
||||
const { DatabaseAnalyser } = require('dbgate-tools');
|
||||
const sql = require('./sql');
|
||||
|
||||
function extractDataType(dataType) {
|
||||
if (!dataType) return {};
|
||||
if (dataType.startsWith('Nullable(')) {
|
||||
dataType = dataType.substring('Nullable('.length, dataType.length - 1);
|
||||
return {
|
||||
dataType,
|
||||
notNull: false,
|
||||
};
|
||||
}
|
||||
return {
|
||||
dataType,
|
||||
notNull: true,
|
||||
};
|
||||
}
|
||||
|
||||
class Analyser extends DatabaseAnalyser {
|
||||
constructor(connection, driver) {
|
||||
super(connection, driver);
|
||||
@@ -23,7 +38,12 @@ class Analyser extends DatabaseAnalyser {
|
||||
...table,
|
||||
primaryKeyColumns: undefined,
|
||||
sortingKeyColumns: undefined,
|
||||
columns: columns.rows.filter((col) => col.pureName == table.pureName),
|
||||
columns: columns.rows
|
||||
.filter((col) => col.pureName == table.pureName)
|
||||
.map((col) => ({
|
||||
...col,
|
||||
...extractDataType(col.dataType),
|
||||
})),
|
||||
primaryKey: { columns: (table.primaryKeyColumns || '').split(',').map((columnName) => ({ columnName })) },
|
||||
sortingKey: { columns: (table.sortingKeyColumns || '').split(',').map((columnName) => ({ columnName })) },
|
||||
foreignKeys: [],
|
||||
|
||||
@@ -8,6 +8,17 @@ const dialect = {
|
||||
rangeSelect: true,
|
||||
stringEscapeChar: "'",
|
||||
fallbackDataType: 'String',
|
||||
|
||||
createColumn: true,
|
||||
dropColumn: true,
|
||||
changeColumn: true,
|
||||
createIndex: true,
|
||||
dropIndex: true,
|
||||
|
||||
columnProperties: {
|
||||
columnComment: true,
|
||||
},
|
||||
|
||||
quoteIdentifier(s) {
|
||||
return `"${s}"`;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user