@@ -699,6 +699,18 @@ def __duckdb_template__(self, **kwargs) -> FakeInterpolation:
699699 compiled = t .compile ()
700700 assert 42 in compiled .params .values ()
701701
702+ def test_supports_duckdb_template_priority_over_iterable (self ):
703+ class IterableWithTemplate :
704+ def __duckdb_template__ (self , ** kwargs ) -> str :
705+ return "SELECT 1"
706+
707+ def __iter__ (self ) -> list [str ]:
708+ return ["SELECT 2" ]
709+
710+ result = template (IterableWithTemplate ()).compile ()
711+ expected = CompiledSql (sql = "SELECT 1" )
712+ assert result == expected
713+
702714
703715# ═══════════════════════════════════════════════════════════════════════════════
704716# IntoInterpolation protocol
@@ -920,18 +932,6 @@ def test_param_object_in_interpolation_preserves_name(self):
920932 expected = CompiledSql (sql = "SELECT $custom_name" , params = {"custom_name" : 42 })
921933 assert result == expected
922934
923- def test_supports_duckdb_template_priority_over_iterable (self ):
924- class IterableWithTemplate :
925- def __duckdb_template__ (self , ** kwargs ) -> str :
926- return "SELECT 1"
927-
928- def __iter__ (self ) -> list [str ]:
929- return ["SELECT 2" ]
930-
931- result = template (IterableWithTemplate ()).compile ()
932- expected = CompiledSql (sql = "SELECT 1" )
933- assert result == expected
934-
935935 def test_same_expression_used_twice (self ):
936936 """Using the same expression twice should create two separate params."""
937937 interp1 = FakeInterpolation (value = 42 , expression = "x" )
0 commit comments