Skip to content

Support DBs without LATERAL JOINS - #917

Open
phdoerfler wants to merge 1 commit into
typelevel:mainfrom
phdoerfler:topic/no-lateral-join-hooks
Open

Support DBs without LATERAL JOINS#917
phdoerfler wants to merge 1 commit into
typelevel:mainfrom
phdoerfler:topic/no-lateral-join-hooks

Conversation

@phdoerfler

@phdoerfler phdoerfler commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

This PR makes support for LATERAL JOINS optional. This has been extracted out of the SQLite branch since it can stand on its own. This way it might be easier to review. It moves the two decisions a backend without lateral joins has to make out of sql-core and behind abstract hooks.

Two abstract members on SqlMappingLike

normalizeOffsetLimit says how a select's OFFSET/LIMIT is fixed up before it is rendered, and unionBranchToFragment how one branch of a union is rendered. defaultOffsetForSubquery is gone, since the first of those covers what it did.

I decided to leave those two abstract and not provide a default implementation. I am not aware of any implementation of SqlMappingLike outside of this repo. And if there is, all it has to do is implement two small methods.

SQL Server's generated SQL changes

SQL Server now emits OFFSET 0 ROWS after an ORDER BY at the root of a query, where before it did so only in subqueries. The rows and their order are unchanged; only the text is. Keeping the old text would have meant passing a "subquery or root?" boolean through the new hook, so I took the text change.

This was referenced Aug 28, 2026
@phdoerfler phdoerfler changed the title Move offset/limit and union-branch rendering behind backend hooks Support DBs without LATERAL JOINS Aug 28, 2026
@phdoerfler
phdoerfler requested a review from milessabin August 28, 2026 20:44
SQL Server emits OFFSET 0 ROWS after a root ORDER BY now, where it only did so in subqueries before.
@phdoerfler
phdoerfler force-pushed the topic/no-lateral-join-hooks branch from b9d0196 to b323089 Compare August 28, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant