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

[5.7] Support UNION aggregate queries #26365

Merged
merged 1 commit into from Nov 4, 2018

Conversation

Projects
None yet
2 participants
@staudenmeir
Contributor

staudenmeir commented Nov 2, 2018

Adds support for UNION aggregate queries:

DB::table('posts')->union(DB::table('videos'))->count();
select count(*) as aggregate from (
    (select * from `posts`) union (select * from `videos`)
) as `temp_table`

This allows the pagination of UNION queries:

DB::table('posts')->union(DB::table('videos'))->orderBy('title')->paginate();

Simple queries like the first example work on SQL Server, pagination doesn't. SQL Server's OFFSET implementation makes this more compIex. I will leave that for another day.

Fixes #24941 and #2968.

@taylorotwell taylorotwell merged commit 9c737f8 into laravel:5.7 Nov 4, 2018

2 checks passed

continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@staudenmeir staudenmeir deleted the staudenmeir:union-aggregate branch Nov 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment