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

Add dump method to Query\Builder class #22193

Closed
wants to merge 3 commits into from
Closed

Add dump method to Query\Builder class #22193

wants to merge 3 commits into from

Conversation

morrislaptop
Copy link
Contributor

Inspired by #19755

This PR adds a dump method to Illuminate\Database\Query\Builder so you can easily debug multiple spots in a query builder chain.

$users = DB::table('users')
           ->select('name', 'email as user_email')
           ->join('contacts', 'users.id', '=', 'contacts.user_id')
           ->union($first)
           ->dump()
           ->where('something', 'true')
           ->orWhere('name', 'John')
           ->orderBy('name', 'desc')
           ->groupBy('account_id')
           ->dump()
           ->offset(10)
           ->limit(5)
           ->having('account_id', '>', 100)
           ->get();

@Dylan-DPC-zz
Copy link

Do check #21796.

@morrislaptop
Copy link
Contributor Author

@Dylan-DPC I had a feeling that would be a bit much, what about just the dump() method?

@Dylan-DPC-zz
Copy link

Actually was pointing more towards Taylor's comment at the bottom (forgot to link the comment).

@morrislaptop
Copy link
Contributor Author

Oh right, I'm referencing #19755 as Collection::dump() was possible through a macro (and was implemented that way in the spatie/laravel-collection-macros repo until it was merged into core).

I'm guessing having this in core would be useful for the developer experience as it follows the same pattern as elsewhere in the framework.

I guess it will be up to @taylorotwell to decide?

@sisve
Copy link
Contributor

sisve commented Nov 24, 2017

I'm strongly against this change (and the Collection::dump()) too. If we continue this path every object in the framework will soon have a dump() method.

@taylorotwell
Copy link
Member

No plans on adding. You can macro it.

@morrislaptop morrislaptop deleted the query-builder-dump branch November 24, 2017 14:35
@morrislaptop
Copy link
Contributor Author

Ok, for anyone else who finds this thread, the macro is available at https://github.com/morrislaptop/laravel-query-builder-dump

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.

4 participants