go-jet / jet

Type safe SQL builder with code generation and automatic query result data mapping
Apache License 2.0
2.52k stars 118 forks source link

Support `FETCH {N} ROWS WITH TIES` for PostgreSQL #299

Closed mingxiang-colorkrew closed 7 months ago

mingxiang-colorkrew commented 9 months ago

Is your feature request related to a problem? Please describe. I would like to be able to use the FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } { ONLY | WITH TIES } functionality in PostgreSQL 13+ onwards with Jet. Currently this keyword is not supported by Jet. https://www.postgresql.org/docs/16/sql-select.html

Screenshot 2023-12-15 at 22 05 00

Describe the solution you'd like Ideally it would be an official supported extension to the SelectStatement so we can compose it in a similar manner to other statements. Alternatively, it would be nice to have an official way to append statements not yet supported by Jet, though I'm not sure what form this could take.

Currently I am working around it by exporting the current statement using stmt.Sql() and appending to the string directly, would like some guidance on what would be the preferred approach for this kind of thing.

houten11 commented 9 months ago

Currently I am working around it by exporting the current statement using stmt.Sql() and appending to the string directly, would like some guidance on what would be the preferred approach for this kind of thing.

I don't see the other way around, except writing the whole query as raw statement.

go-jet commented 7 months ago

FETCH_FIRST/FETCH_LAST WITH TIES support added in Release v2.11.0.