MCPcopy
hub / github.com/chartdb/chartdb / compareFieldProperties

Function compareFieldProperties

src/lib/domain/diff/diff-check/diff-check.ts:770–931  ·  view source on GitHub ↗
({
    tableId,
    oldField,
    newField,
    diffMap,
    changedTables,
    changedFields,
    attributes,
    changedTablesAttributes,
    changedFieldsAttributes,
}: {
    tableId: string;
    oldField: DBField;
    newField: DBField;
    diffMap: DiffMap;
    changedTables: Map<string, boolean>;
    changedFields: Map<string, boolean>;
    attributes?: FieldDiffAttribute[];
    changedTablesAttributes?: TableDiffAttribute[];
    changedFieldsAttributes?: FieldDiffAttribute[];
})

Source from the content-addressed store, hash-verified

768
769// Compare field properties
770function compareFieldProperties({
771 tableId,
772 oldField,
773 newField,
774 diffMap,
775 changedTables,
776 changedFields,
777 attributes,
778 changedTablesAttributes,
779 changedFieldsAttributes,
780}: {
781 tableId: string;
782 oldField: DBField;
783 newField: DBField;
784 diffMap: DiffMap;
785 changedTables: Map<string, boolean>;
786 changedFields: Map<string, boolean>;
787 attributes?: FieldDiffAttribute[];
788 changedTablesAttributes?: TableDiffAttribute[];
789 changedFieldsAttributes?: FieldDiffAttribute[];
790}) {
791 // If attributes are specified, only check those attributes
792 const attributesToCheck: FieldDiffAttribute[] = attributes ?? [
793 'name',
794 'type',
795 'primaryKey',
796 'unique',
797 'nullable',
798 'comments',
799 'characterMaximumLength',
800 'scale',
801 'precision',
802 'increment',
803 'isArray',
804 ];
805
806 const changedAttributes: FieldDiffAttribute[] = [];
807
808 if (attributesToCheck.includes('name') && oldField.name !== newField.name) {
809 changedAttributes.push('name');
810 }
811
812 if (
813 attributesToCheck.includes('type') &&
814 oldField.type.id !== newField.type.id
815 ) {
816 changedAttributes.push('type');
817 }
818
819 if (
820 attributesToCheck.includes('primaryKey') &&
821 oldField.primaryKey !== newField.primaryKey
822 ) {
823 changedAttributes.push('primaryKey');
824 }
825
826 if (
827 attributesToCheck.includes('unique') &&

Callers 1

compareFieldsFunction · 0.85

Calls 5

areCommentsDifferentFunction · 0.85
isOneOfDefinedFunction · 0.85
normalizeBooleanFunction · 0.85
shouldAddToChangedMapFunction · 0.85
getDiffMapKeyFunction · 0.85

Tested by

no test coverage detected