-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[RFC] Expose QueryBuilder::getType #11813
Conversation
Sounds reasonable to me. What do the others think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you show us the piece of code where you need this, in case we can see another way?
src/QueryBuilder.php
Outdated
@@ -128,6 +127,11 @@ public function __construct( | |||
$this->parameters = new ArrayCollection(); | |||
} | |||
|
|||
public function getType(): QueryType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not open this too much, shall we?
public function getType(): QueryType | |
final protected function getType(): QueryType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I remove the test then ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is getting philosophical… I think protected method are part of the public API, so you should keep testing them. You could have
$qb = new class extends QueryBuilder
{
public method assertCallingUpdateMakesTheQueryAnUpdate(): void
{
$this->update();
TestCase::assertSame(QueryType::UPDATE, $this->getType());
}
}
$qb->assertCallingUpdateMakesTheQueryAnUpdate();
We have a method to batch Queries when the array of element is too big / the query too slow.
Now I'd like to get the result.
Also, technically I should handle the case where I could use
|
Please squash |
f29b43f
to
d7ac612
Compare
Sure, done |
Thanks @VincentLanglet ! |
I have an implementation where I extends the QueryBuilder in order to provide extra methods.
In one of them, I'd like an easy way to know if the queryBuilder is creating a select, an update or a delete query.
I could extends
select
,addSelect
,update
anddelete
to keep a state with the type of the current query, but it seems like the QueryBuilder already does this. So I'd like to expose this information.Are you okay with this ?