mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 06:53:58 +00:00
fix: use only cols with comments for obj hash
This commit is contained in:
@@ -90,7 +90,7 @@ function getColumnInfo({
|
|||||||
/**
|
/**
|
||||||
* @param {ReturnType<objectTypeToField>} fieldType
|
* @param {ReturnType<objectTypeToField>} fieldType
|
||||||
* @param {any} item
|
* @param {any} item
|
||||||
* @param {Array<{ objectId: string; columnComment: string }>} columns
|
* @param {Array<{ objectId: string; columnId: number, columnComment: string }>} columns
|
||||||
* @returns {string|null}
|
* @returns {string|null}
|
||||||
*/
|
*/
|
||||||
function createObjectContentHash(fieldType, item, columns) {
|
function createObjectContentHash(fieldType, item, columns) {
|
||||||
@@ -100,12 +100,13 @@ function createObjectContentHash(fieldType, item, columns) {
|
|||||||
if ((columns?.length && fieldType === 'tables') || fieldType === 'views') {
|
if ((columns?.length && fieldType === 'tables') || fieldType === 'views') {
|
||||||
const modifyDateStr = modifyDate ? modifyDate.toISOString() : '';
|
const modifyDateStr = modifyDate ? modifyDate.toISOString() : '';
|
||||||
const objectColumns = columns.filter(col => col.objectId == item.objectId);
|
const objectColumns = columns.filter(col => col.objectId == item.objectId);
|
||||||
const colsComments = objectColumns.map(i => i.columnComment).join(',');
|
const colsComments = objectColumns
|
||||||
|
.filter(i => i.columnComment)
|
||||||
|
.map(i => `${i.columnId}/${i.columnComment}`)
|
||||||
|
.join('||');
|
||||||
|
const objectComment = item.objectComment || '';
|
||||||
|
|
||||||
return crypto
|
return crypto.createHash('sha256').update(`${modifyDateStr}:${colsComments}:${objectComment}`).digest('hex');
|
||||||
.createHash('sha256')
|
|
||||||
.update(modifyDateStr + colsComments)
|
|
||||||
.digest('hex');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!modifyDate) return null;
|
if (!modifyDate) return null;
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
module.exports = `
|
module.exports = `
|
||||||
select c.object_id as objectId,
|
select c.object_id as objectId,
|
||||||
ep.value as columnComment
|
ep.value as columnComment,
|
||||||
|
c.column_id as columnId
|
||||||
from sys.columns c
|
from sys.columns c
|
||||||
inner join sys.objects o on c.object_id = o.object_id
|
inner join sys.objects o on c.object_id = o.object_id
|
||||||
INNER JOIN sys.schemas u ON u.schema_id=o.schema_id
|
INNER JOIN sys.schemas u ON u.schema_id=o.schema_id
|
||||||
left join sys.extended_properties ep on ep.major_id = c.object_id and ep.minor_id = c.column_id and ep.name = 'MS_Description'
|
INNER JOIN sys.extended_properties ep on ep.major_id = c.object_id and ep.minor_id = c.column_id and ep.name = 'MS_Description'
|
||||||
where o.type IN ('U', 'V') and o.object_id =OBJECT_ID_CONDITION and u.name =SCHEMA_NAME_CONDITION
|
where o.type IN ('U', 'V') and o.object_id =OBJECT_ID_CONDITION and u.name =SCHEMA_NAME_CONDITION
|
||||||
order by c.column_id
|
order by c.column_id
|
||||||
`;
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user