yiisoft / db

Yii Database Library
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
132 stars 36 forks source link

Support FETCH n FIRST/NEXT ROWS expression for limit #222

Open Insolita opened 3 years ago

Insolita commented 3 years ago

Postgres since 13, and oracle since 12 ver support expression

OFFSET start { ROW | ROWS } FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } { ONLY | WITH TIES }

MariaDb also supports since 10.6 https://mariadb.com/kb/en/select-offset-fetch/

Right now there is no way to use it with QueryBuilder.

Propose for add ability to add fetch() construction or allow custom Expression for limit() without "LIMIT" prefix if it starts with "FETCH" at this place https://github.com/yiisoft/db/blob/48e2a815263f7da5b02fa4f88f1bc1bb106c8e27/src/Query/QueryBuilder.php#L1724

same for yii2 https://github.com/yiisoft/yii2/issues/18639

Insolita commented 3 years ago

@samdark , see yii3 chat, there are many ideas, limit('FETCH x ...') , separate fetch(), common appendClause() method