@@ -1187,15 +1187,6 @@ def _build_pipeline(self, source: "PipelineSource"):
11871187 orderings .append (pipeline_expressions .Ordering (field , direction ))
11881188
11891189 if orderings :
1190- # Normalize cursors to get the raw values corresponding to the orders
1191- start_at_val = None
1192- if self ._start_at :
1193- start_at_val = self ._normalize_cursor (self ._start_at , normalized_orders )
1194-
1195- end_at_val = None
1196- if self ._end_at :
1197- end_at_val = self ._normalize_cursor (self ._end_at , normalized_orders )
1198-
11991190 # If limit_to_last is set, we need to reverse the orderings to find the
12001191 # "last" N documents (which effectively become the "first" N in reverse order).
12011192 if self ._limit_to_last :
@@ -1205,14 +1196,17 @@ def _build_pipeline(self, source: "PipelineSource"):
12051196 # Apply cursor conditions.
12061197 # Cursors are translated into filter conditions (e.g., field > value)
12071198 # based on the orderings.
1208- if start_at_val :
1199+ if self ._start_at :
1200+ # Normalize cursors to get the raw values corresponding to the orders
1201+ start_at_val = self ._normalize_cursor (self ._start_at , normalized_orders )
12091202 ppl = ppl .where (
12101203 _where_conditions_from_cursor (
12111204 start_at_val , orderings , is_start_cursor = True
12121205 )
12131206 )
12141207
1215- if end_at_val :
1208+ if self ._end_at :
1209+ end_at_val = self ._normalize_cursor (self ._end_at , normalized_orders )
12161210 ppl = ppl .where (
12171211 _where_conditions_from_cursor (
12181212 end_at_val , orderings , is_start_cursor = False
0 commit comments