Skip to content

H2Dialect.LimitClause produces invalid SQL instead of standard OFFSET / FETCH #1287

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

Closed
katzyn opened this issue Jul 6, 2022 · 0 comments
Closed
Assignees
Labels
type: bug A general bug

Comments

@katzyn
Copy link

katzyn commented Jul 6, 2022

H2 officially supports only OFFSET / FETCH from the SQL Standard:
https://h2database.com/html/commands.html#select
H2 accepts it unconditionally (even in compatibility modes for database systems without its support).

But H2Dialect produces non-standard LIMIT / OFFSET for a some reason:

public String getLimit(long limit) {
return "LIMIT " + limit;
}
@Override
public String getOffset(long offset) {
return "OFFSET " + offset;
}
@Override
public String getLimitOffset(long limit, long offset) {
return String.format("LIMIT %d OFFSET %d", limit, offset);
}

H2 accepts this legacy syntax only in Regular, Legacy, DB2, HSQLDB, MariaDB, MySQL, and PostgreSQL compatibility modes.
https://h2database.com/html/features.html#compatibility

It isn't accepted in Strict, Derby, MSSQLServer, and Oracle compatibility modes and it causes syntax errors like that one:
https://stackoverflow.com/questions/72880912/spring-boot-2-7-1-with-data-r2dbc-findbyid-fails-when-using-h2-with-mssqlserve

@katzyn katzyn changed the title H2Dialectу.LimitClause produces invalid SQL instead of standard OFFSET / FETCH H2Dialect.LimitClause produces invalid SQL instead of standard OFFSET / FETCH Jul 6, 2022
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 6, 2022
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 7, 2022
@mp911de mp911de self-assigned this Jul 7, 2022
@mp911de mp911de added this to the 2.4.3 (2021.2.3) milestone Jul 21, 2022
schauder pushed a commit that referenced this issue Aug 10, 2022
Reuse H2 dialect settings in R2DBC-specific H2 dialect.
Refactor ArrayColumns support classes, into toplevel-types. Let R2DBC H2 sublass the relational H2Dialect to decouple from Postgres.

See #1287
Original pull request #1297
schauder pushed a commit that referenced this issue Mar 30, 2023
As per suggestion of the H2 maintainer.

Closes #1287
Original pull request #1297
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants