Skip to content

Commit

Permalink
Fix issue with plan when adding/removing fields
Browse files Browse the repository at this point in the history
  • Loading branch information
b-per committed Dec 11, 2024
1 parent c4b14f1 commit 1219299
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies = [
"click<9.0.0,>=8.1.3",
"requests<3.0.0,>=2.32.0",
"loguru<1.0.0,>=0.6.0",
"deepdiff<7.0.0,>=6.2.2",
"deepdiff>=8.0.0,<9.0.0",
"pydantic<3.0.0,>=2.0.0",
"croniter<2.0.0,>=1.3.8",
"ruamel-yaml<1.0.0,>=0.17.21",
Expand All @@ -20,7 +20,7 @@ dependencies = [
"importlib-metadata<7,>=6.0",
]
name = "dbt-jobs-as-code"
version = "1.0.0"
version = "1.0.1"
description = "A CLI to allow defining dbt Cloud jobs as code"
readme = "README.md"
keywords = [
Expand Down
8 changes: 7 additions & 1 deletion src/dbt_jobs_as_code/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@ def check_job_mapping_same(source_job: JobDefinition, dest_job: JobDefinition) -
logger.success(f"✅ Job {source_job.identifier} is identical")
return True
else:
# we can't json.dump types normally, so we provide a custom logic to just return the type name
def type_serializer(obj):
if isinstance(obj, type):
return obj.__name__
raise TypeError(f"Object of type {type(obj).__name__} is not JSON serializable")

logger.info(
f"❌ Job {source_job.identifier} is different - Diff:\n{json.dumps(diffs, indent=2)}"
f"❌ Job {source_job.identifier} is different - Diff:\n{json.dumps(diffs, indent=2, default=type_serializer)}"
)
return False

Expand Down
34 changes: 34 additions & 0 deletions tests/schemas/test_check_job_mapping_same.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from dbt_jobs_as_code.schemas import check_job_mapping_same
from dbt_jobs_as_code.schemas.job import JobDefinition


def test_check_job_mapping_same():
mock_job1 = JobDefinition(
id=1,
name="Job 1",
project_id=100,
environment_id=200,
account_id=300,
settings={},
run_generate_sources=False,
execute_steps=[],
generate_docs=False,
schedule={"cron": "0 14 * * 0,1,2,3,4,5,6"},
triggers={},
)
mock_job2 = JobDefinition(
id=2,
name="Job 2",
project_id=100,
environment_id=400,
account_id=300,
deferring_environment_id=400,
settings={},
run_generate_sources=False,
execute_steps=[],
generate_docs=False,
schedule={"cron": "0 14 * * 0,1,2,3,4,5,6"},
triggers={},
)

assert check_job_mapping_same(mock_job1, mock_job2) == False
18 changes: 9 additions & 9 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1219299

Please sign in to comment.