Skip to content

Commit 17dc9c9

Browse files
committed
fix: clarify list query comment markers and add stability notes
Update documentation and placeholder comments to reflect current query rewriter behavior: rename query.cursor and query.filter to query.where, rename query.order to query.order_by, and add notes about primary key tie-breaker stability for keyset pagination.
1 parent 76557ac commit 17dc9c9

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

internal/sqlc/template/template.sql.tmpl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,10 @@ INSERT INTO {{.Table.Name}} (
267267

268268
-- List{{table_name .Table.Name "many"}} retrieves a paginated list of rows from '{{$.Table.Name}}'.
269269
--
270-
-- Filtering, cursor, and ordering:
270+
-- Filtering and ordering:
271271
-- The commented markers in WHERE and ORDER BY are placeholders for a runtime
272-
-- query rewriter (e.g. sqlc-gen-template) to substitute cursor, filter, and
273-
-- order expressions. When left unreplaced they remain SQL comments, so the
272+
-- query rewriter (e.g. sqlc-gen-template) to substitute filter and order
273+
-- expressions. When left unreplaced they remain SQL comments, so the
274274
-- query returns all rows ordered by primary key.
275275
--
276276
-- Offset pagination:
@@ -281,11 +281,11 @@ SELECT
281281
FROM
282282
{{$.Table.Name}}
283283
WHERE
284-
/* query.cursor AND */ /* query.filter AND */ TRUE
284+
/* query.where AND */ TRUE
285285
{{- $query_order := query_order $.Table}}
286286
{{- if $query_order}}
287287
ORDER BY
288-
/* query.order , */ {{$query_order}}
288+
/* query.order_by , */ {{$query_order}} -- PK tie-breaker; keyset stability
289289
{{- end}}
290290
LIMIT
291291
sqlc.narg(take)::int
@@ -297,10 +297,10 @@ OFFSET
297297

298298
-- List{{table_name $.Table.Name "many"}}{{query_index $key}} retrieves a paginated list of rows from '{{$.Table.Name}}'{{if $key.Name}} filtered by {{$key.Name}}{{end}}.
299299
--
300-
-- Filtering, cursor, and ordering:
300+
-- Filtering and ordering:
301301
-- The commented markers in WHERE and ORDER BY are placeholders for a runtime
302-
-- query rewriter (e.g. sqlc-gen-template) to substitute cursor, filter, and
303-
-- order expressions. When left unreplaced they remain SQL comments, so the
302+
-- query rewriter (e.g. sqlc-gen-template) to substitute filter and order
303+
-- expressions. When left unreplaced they remain SQL comments, so the
304304
-- query returns all matching rows ordered by primary key.
305305
--
306306
-- Offset pagination:
@@ -312,11 +312,11 @@ FROM
312312
{{$.Table.Name}}
313313
{{- $condition := query_condition $.Table $key}}
314314
WHERE
315-
/* query.cursor AND */ /* query.filter AND */ {{if $condition}}{{$condition}}{{else}}TRUE{{end}}
315+
/* query.where AND */ {{if $condition}}{{$condition}}{{else}}TRUE{{end}}
316316
{{- $query_order := query_order $.Table}}
317317
{{- if $query_order}}
318318
ORDER BY
319-
/* query.order , */ {{$query_order}}
319+
/* query.order_by , */ {{$query_order}} -- PK tie-breaker; keyset stability
320320
{{- end}}
321321
LIMIT
322322
sqlc.narg(take)::int

0 commit comments

Comments
 (0)