mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 12:35:59 +00:00
cockroach fk analyse fix
This commit is contained in:
@@ -41,7 +41,9 @@ class Analyser extends DatabaseAnalyser {
|
||||
}
|
||||
|
||||
createQuery(resFileName, typeFields) {
|
||||
return super.createQuery(sql[resFileName], typeFields);
|
||||
return super
|
||||
.createQuery(sql[resFileName], typeFields)
|
||||
.replace('#REFTABLECOND#', this.driver.__analyserInternals.refTableCond);
|
||||
}
|
||||
|
||||
async _computeSingleObjectId() {
|
||||
|
||||
@@ -12,7 +12,7 @@ select
|
||||
refcol.column_name as "ref_column_name"
|
||||
from information_schema.referential_constraints fk
|
||||
inner join information_schema.table_constraints base on fk.constraint_name = base.constraint_name and fk.constraint_schema = base.constraint_schema
|
||||
inner join information_schema.table_constraints ref on fk.unique_constraint_name = ref.constraint_name and fk.unique_constraint_schema = ref.constraint_schema
|
||||
inner join information_schema.table_constraints ref on fk.unique_constraint_name = ref.constraint_name and fk.unique_constraint_schema = ref.constraint_schema #REFTABLECOND#
|
||||
inner join information_schema.key_column_usage basecol on base.table_name = basecol.table_name and base.constraint_name = basecol.constraint_name
|
||||
inner join information_schema.key_column_usage refcol on ref.table_name = refcol.table_name and ref.constraint_name = refcol.constraint_name and basecol.ordinal_position = refcol.ordinal_position
|
||||
where
|
||||
|
||||
@@ -33,6 +33,10 @@ const postgresDriverBase = {
|
||||
showConnectionField: (field, values) =>
|
||||
['server', 'port', 'user', 'password', 'defaultDatabase', 'singleDatabase'].includes(field),
|
||||
getQuerySplitterOptions: () => postgreSplitterOptions,
|
||||
|
||||
__analyserInternals: {
|
||||
refTableCond: '',
|
||||
}
|
||||
};
|
||||
|
||||
/** @type {import('dbgate-types').EngineDriver} */
|
||||
@@ -59,6 +63,9 @@ const cockroachDriver = {
|
||||
dropColumnDependencies: ['primaryKey'],
|
||||
dropPrimaryKey: false,
|
||||
},
|
||||
__analyserInternals: {
|
||||
refTableCond: 'and fk.referenced_table_name = ref.table_name',
|
||||
}
|
||||
};
|
||||
|
||||
/** @type {import('dbgate-types').EngineDriver} */
|
||||
|
||||
Reference in New Issue
Block a user