Skip to content

Commit 3d322cf

Browse files
committed
fix: report oversized rendered constants as compile errors
1 parent 14e03cd commit 3d322cf

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

‎crates/sqlbuild-python/src/bindings/_helpers/render/declaration_values.rs‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,7 @@ fn rendered_constant<'py>(
368368
declaration.getattr("name")?.str()?
369369
);
370370
return Err(PyErr::from_value(
371-
imported(
372-
declaration.py(),
373-
SQL_VALUE_ERRORS_MODULE,
374-
"SqlValueValidationError",
375-
)?
371+
imported(declaration.py(), NATIVE_MODULE, "SqlValueValidationError")?
376372
.call1((format!(
377373
"{context} rendered value is {size} bytes; maximum is {MAX_SQL_VALUE_SIZE} bytes"
378374
),))?,

‎tests/unit/src/sqlbuild/compiler/compile/_helpers/test_declarations.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,14 @@ def test_given_declaration_change_when_compiling_then_updates_dependent_identity
610610
"constants/groups.sql constant 'groups'.*adapter 'duckdb'.*value_list"
611611
),
612612
),
613+
CompileDeclarationsErrorTestCase(
614+
description="constant rendered over the SQL value size limit",
615+
repo_files={
616+
"constants/big.sql": f'CONSTANT (name big, value "{"'" * 600_000}");',
617+
"models/orders.sql": 'MODEL (description "Test model orders.");\nSELECT @const("big") AS big\n',
618+
},
619+
expected_error_fragment="constants/big.sql constant 'big'.*maximum is 1000000 bytes",
620+
),
613621
],
614622
ids=lambda case: case.description,
615623
)

0 commit comments

Comments
 (0)