StructureRev: use deep equals for structure revision change detection (#53920)
This commit is contained in:
@@ -183,7 +183,7 @@ describe('test comparisons', () => {
|
||||
expect(compareDataFrameStructures(a, b)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('does not compare deeply', () => {
|
||||
it('does deep comparison', () => {
|
||||
const a = {
|
||||
...frameB,
|
||||
fields: [
|
||||
@@ -218,7 +218,7 @@ describe('test comparisons', () => {
|
||||
],
|
||||
};
|
||||
|
||||
expect(compareDataFrameStructures(a, b)).toBeFalsy();
|
||||
expect(compareDataFrameStructures(a, b)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
import { DataFrame } from '../types/dataFrame';
|
||||
|
||||
/**
|
||||
@@ -8,10 +10,6 @@ import { DataFrame } from '../types/dataFrame';
|
||||
* ```
|
||||
* compareArrayValues(a, b, framesHaveSameStructure);
|
||||
* ```
|
||||
* NOTE: this does a shallow check on the FieldConfig properties, when using the query
|
||||
* editor, this should be sufficient, however if applications are mutating properties
|
||||
* deep in the FieldConfig this will not recognize a change
|
||||
*
|
||||
* @beta
|
||||
*/
|
||||
export function compareDataFrameStructures(a: DataFrame, b: DataFrame, skipConfig?: boolean): boolean {
|
||||
@@ -63,11 +61,9 @@ export function compareDataFrameStructures(a: DataFrame, b: DataFrame, skipConfi
|
||||
if (key === 'interval') {
|
||||
continue;
|
||||
}
|
||||
if (key === 'custom') {
|
||||
if (!shallowCompare(cfgA[key], cfgB[key])) {
|
||||
return false;
|
||||
}
|
||||
} else if (cfgA[key] !== cfgB[key]) {
|
||||
|
||||
// Deep comparison on all object properties
|
||||
if (!isEqual(cfgA[key], cfgB[key])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user