diff --git a/tests/trace/test_objects_query_builder.py b/tests/trace/test_objects_query_builder.py index 758cf9cfbb1..0fdb888e3bb 100644 --- a/tests/trace/test_objects_query_builder.py +++ b/tests/trace/test_objects_query_builder.py @@ -55,10 +55,10 @@ def test_make_conditions_part(): def test_make_object_id_conditions_part(): assert _make_object_id_conditions_part(None) == "" assert _make_object_id_conditions_part([]) == "" - assert _make_object_id_conditions_part(["id = 1"]) == "AND id = 1" + assert _make_object_id_conditions_part(["id = 1"]) == " AND id = 1" assert ( _make_object_id_conditions_part(["id = 1", "id = 2"]) - == "AND ((id = 1) AND (id = 2))" + == " AND ((id = 1) AND (id = 2))" ) diff --git a/weave/trace_server/objects_query_builder.py b/weave/trace_server/objects_query_builder.py index c5b63b2af97..2df6c719eb4 100644 --- a/weave/trace_server/objects_query_builder.py +++ b/weave/trace_server/objects_query_builder.py @@ -68,7 +68,7 @@ def _make_object_id_conditions_part(object_id_conditions: Optional[list[str]]) - if not object_id_conditions: return "" conditions_str = combine_conditions(object_id_conditions, "AND") - return _make_optional_part("AND", conditions_str) + return " " + _make_optional_part("AND", conditions_str) def format_metadata_objects_from_query_result( @@ -236,7 +236,7 @@ def make_metadata_query(self) -> str: ORDER BY created_at ASC ) AS rn FROM object_versions - WHERE project_id = {{project_id: String}} {self.object_id_conditions_part} + WHERE project_id = {{project_id: String}}{self.object_id_conditions_part} ) WHERE rn = 1 )"""