Skip to content

Fix ordered SQL Server UNION branches - #322

Merged
elpete merged 1 commit into
nextfrom
fix/issue-201-sqlserver-ordered-unions
Aug 12, 2026
Merged

Fix ordered SQL Server UNION branches#322
elpete merged 1 commit into
nextfrom
fix/issue-201-sqlserver-ordered-unions

Conversation

@elpete

@elpete elpete commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Closes #201

What changed

  • compile independently ordered and limited SQL Server UNION branches as derived queries
  • preserve TOP and ORDER BY within each branch so each source contributes its intended top rows
  • retain the existing compilation and validation behavior for ordinary UNION queries
  • add a regression test based on the issue reproduction

Root cause

qb treated the root orderBy() as the final UNION ordering and rejected every orderBy() on a unioned builder. SQL Server can support the requested top-N-per-source operation, but each ordered TOP query must be isolated as a derived query rather than emitted directly as a UNION operand.

Validation

  • TestBox on Lucee 6: 2,773 passed, 0 failed, 3 skipped
  • box run-script format:check
  • git diff --check

@elpete
elpete force-pushed the fix/issue-201-sqlserver-ordered-unions branch from 8acd629 to b55422d Compare August 12, 2026 20:50
@elpete
elpete marked this pull request as ready for review August 12, 2026 20:56
@elpete
elpete merged commit 508e5be into next Aug 12, 2026
33 of 35 checks passed
@elpete
elpete deleted the fix/issue-201-sqlserver-ordered-unions branch August 12, 2026 20:56
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