mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 02:06:01 +00:00
fix analyser for cockroach
This commit is contained in:
@@ -162,9 +162,25 @@ const drivers = driverBases.map(driverBase => ({
|
||||
async getVersion(client) {
|
||||
const { rows } = await this.query(client, 'SELECT version()');
|
||||
const { version } = rows[0];
|
||||
|
||||
const isCockroach = version.toLowerCase().includes('cockroachdb');
|
||||
const isRedshift = version.toLowerCase().includes('redshift');
|
||||
const isPostgres = !isCockroach && !isRedshift;
|
||||
|
||||
const m = version.match(/([\d\.]+)/);
|
||||
let versionText = null;
|
||||
if (m) {
|
||||
if (isCockroach) versionText = `CockroachDB ${m[1]}`;
|
||||
if (isRedshift) versionText = `Redshift ${m[1]}`;
|
||||
if (isPostgres) versionText = `PostgreSQL ${m[1]}`;
|
||||
}
|
||||
|
||||
return {
|
||||
version,
|
||||
versionText: (version || '').replace(/\s*\(.*$/, ''),
|
||||
versionText,
|
||||
isPostgres,
|
||||
isCockroach,
|
||||
isRedshift,
|
||||
};
|
||||
},
|
||||
async readQuery(client, sql, structure) {
|
||||
|
||||
@@ -2,8 +2,8 @@ module.exports = `
|
||||
select infoTables.table_schema as "schema_name", infoTables.table_name as "pure_name",
|
||||
(
|
||||
select md5(string_agg(
|
||||
infoColumns.column_name || '|' || infoColumns.data_type || '|' || infoColumns.is_nullable || '|' || coalesce(infoColumns.character_maximum_length, -1)
|
||||
|| '|' || coalesce(infoColumns.numeric_precision, -1),
|
||||
infoColumns.column_name || '|' || infoColumns.data_type || '|' || infoColumns.is_nullable::varchar(255) || '|' || coalesce(infoColumns.character_maximum_length, -1)::varchar(255)
|
||||
|| '|' || coalesce(infoColumns.numeric_precision, -1)::varchar(255) ,
|
||||
',' order by infoColumns.ordinal_position
|
||||
)) as "hash_code_columns"
|
||||
from information_schema.columns infoColumns
|
||||
|
||||
Reference in New Issue
Block a user