Compare commits

...

2 Commits

Author SHA1 Message Date
Jeremy Cohen
879957a65e Build checksums during same_contract 2023-07-05 11:55:45 +02:00
Jeremy Cohen
434d491b0d Always build contract checksum for versioned model 2023-07-05 11:55:22 +02:00
2 changed files with 13 additions and 0 deletions

View File

@@ -625,6 +625,11 @@ class ModelNode(CompiledNode):
# We don't need to construct the checksum if the model does not
# have contract enforced, because it won't be used.
# This needs to be executed after contract config is set
# Should we make this a no-op, if the checksum already exists?
if self.contract.checksum is not None:
pass
if self.contract.enforced is True:
contract_state = ""
# We need to sort the columns so that order doesn't matter
@@ -649,6 +654,12 @@ class ModelNode(CompiledNode):
# Now it's enforced. This is a change, but not a breaking change -- same_contract: False
return False
if not self.contract.checksum:
self.build_contract_checksum()
if not old.contract.checksum:
old.build_contract_checksum()
# Otherwise: The contract was previously enforced, and we need to check for changes.
# Happy path: The contract is still being enforced, and the checksums are identical.
if self.contract.enforced is True and self.contract.checksum == old.contract.checksum:

View File

@@ -784,6 +784,8 @@ class ModelPatchParser(NodePatchParser[UnparsedModelUpdate]):
# Includes alias recomputation
self.patch_node_config(versioned_model_node, versioned_model_patch)
# Need to reapply this here, in the case that 'contract: {enforced: true}' was during config-setting
versioned_model_node.build_contract_checksum()
source_file.append_patch(
versioned_model_patch.yaml_key, versioned_model_node.unique_id
)