yiisoft / yiisoft/db

Support FETCH n FIRST/NEXT ROWS expression for limit

Open
#222 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status:ready for adoption type:enhancement
Dominant language
PHP
Stars
216
Forks
51
Avg merge
3d 10h
Merged PRs (30d)
2

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/Query/QueryBuilder.php around line 1724, where limit expressions receive their SQL prefix. Read the linked Yii2 issue and compare the requested fetch() construction with allowing a custom FETCH expression; done means QueryBuilder can represent the documented FETCH FIRST/NEXT syntax for the supported database dialects without breaking existing limit behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
mariadb, php, postgresql
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.