mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-26 23:46:23 +00:00
clickhouse: nullable types
This commit is contained in:
@@ -1,6 +1,21 @@
|
|||||||
const { DatabaseAnalyser } = require('dbgate-tools');
|
const { DatabaseAnalyser } = require('dbgate-tools');
|
||||||
const sql = require('./sql');
|
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 {
|
class Analyser extends DatabaseAnalyser {
|
||||||
constructor(connection, driver) {
|
constructor(connection, driver) {
|
||||||
super(connection, driver);
|
super(connection, driver);
|
||||||
@@ -23,7 +38,12 @@ class Analyser extends DatabaseAnalyser {
|
|||||||
...table,
|
...table,
|
||||||
primaryKeyColumns: undefined,
|
primaryKeyColumns: undefined,
|
||||||
sortingKeyColumns: 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 })) },
|
primaryKey: { columns: (table.primaryKeyColumns || '').split(',').map((columnName) => ({ columnName })) },
|
||||||
sortingKey: { columns: (table.sortingKeyColumns || '').split(',').map((columnName) => ({ columnName })) },
|
sortingKey: { columns: (table.sortingKeyColumns || '').split(',').map((columnName) => ({ columnName })) },
|
||||||
foreignKeys: [],
|
foreignKeys: [],
|
||||||
|
|||||||
@@ -8,6 +8,17 @@ const dialect = {
|
|||||||
rangeSelect: true,
|
rangeSelect: true,
|
||||||
stringEscapeChar: "'",
|
stringEscapeChar: "'",
|
||||||
fallbackDataType: 'String',
|
fallbackDataType: 'String',
|
||||||
|
|
||||||
|
createColumn: true,
|
||||||
|
dropColumn: true,
|
||||||
|
changeColumn: true,
|
||||||
|
createIndex: true,
|
||||||
|
dropIndex: true,
|
||||||
|
|
||||||
|
columnProperties: {
|
||||||
|
columnComment: true,
|
||||||
|
},
|
||||||
|
|
||||||
quoteIdentifier(s) {
|
quoteIdentifier(s) {
|
||||||
return `"${s}"`;
|
return `"${s}"`;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user