Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOTFIX] - User correct OFFSET/LIMIT syntax for MSSQL #25

Merged
merged 4 commits into from
Dec 4, 2023

Conversation

joshmcrae
Copy link
Member

This PR extends SELECT query SQL generation for MSSQL so that the correct syntax is used when a query is built with the
->limit() or ->offset() methods. Standard SQL does not work and clause of the form OFFSET n ROWS FETCH NEXT n ROWS ONLY must be used instead.

Because these clauses were being generated directly in the Table class when the corresponding methods are called, the responsibility has been extract into Driver/Base::getLimitClause(). A default implementation exists here, mirroring the existing functionality for all drivers, and a special implementation has been added via an override in Driver/Mssql.

Closes #24.

Copy link

@ryanrigby17 ryanrigby17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just this I think.

lib/PicoDb/Driver/Mssql.php Show resolved Hide resolved
@joshmcrae joshmcrae dismissed ryanrigby17’s stale review December 4, 2023 22:57

Changes have been addressed

@joshmcrae joshmcrae merged commit 3ed1c0a into master Dec 4, 2023
8 checks passed
@joshmcrae joshmcrae deleted the mssql-offset-limit branch December 4, 2023 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Using OFFSET with Microsoft SQL Server produces syntax error
3 participants