-- name: get_plot_lists :many
WITH grouped_lists AS (
SELECTl.id,
l.name,
l.created_at,
array_agg(p2l.cadastral_number) AS cadastral_numbers
FROMpublic.plot_listsAS l
LEFT JOINpublic.land_plot2plot_listAS p2l ONl.id=p2l.plot_list_idGROUP BYl.id, l.name
)
SELECTgl.name,
gl.cadastral_numbers,
(SELECTCOUNT(*) FROMpublic.plot_lists) AS total
FROM grouped_lists gl
ORDER BYgl.created_atLIMIT @pagination_limit OFFSET (@page -1) * @pagination_limit;
This sql query gives next python function:
asyncdefget_plot_lists(self, *, -page: Optional[Any], pagination_limit: int) ->AsyncIterator[get_plot_listsRow]:
result=awaitself._conn.stream(sqlalchemy.text(GET_PLOT_LISTS), {"p1": -page, "p2": pagination_limit})
asyncforrowinresult:
yieldget_plot_listsRow(
name=row[0],
cadastral_numbers=row[1],
total=row[2],
)'page' arg generated with '-' as prefix.
-> % sqlc version
v1.28.0
plugins:
- name: py
wasm:
url: https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.3.0.wasm
sha256: fbedae96b5ecae2380a70fb5b925fd4bff58a6cfb1f3140375d098fbab7b3a3c
This sql query gives next python function:
'page' arg generated with '-' as prefix.