-
Notifications
You must be signed in to change notification settings - Fork 102
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
Improve QueryResultDynamicReturnTypeExtension #520
Conversation
Alright, I'm gonna look at this again after #506 is merged. |
4dea7a1
to
7f2adbc
Compare
From #453 (comment)
This is fixed by the commit 1b0a1b0
I'm curious about this "bug" because Did you kept any example of query with your issue @ondrejmirtes ? |
d4d98e5
to
aded0cf
Compare
Please fix the conflicts. |
@@ -175,6 +179,7 @@ public function walkSelectStatement(AST\SelectStatement $AST): string | |||
$this->typeBuilder->setSelectQuery(); | |||
$this->hasAggregateFunction = $this->hasAggregateFunction($AST); | |||
$this->hasGroupByClause = $AST->groupByClause !== null; | |||
$this->hasWhereClause = $AST->whereClause !== null; |
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.
Are you sure this ever works? Because QueryBuilderGetQueryDynamicReturnTypeExtension::METHODS_NOT_AFFECTING_RESULT_TYPE
contains all where methods.
And if you remove those, you will break codebases using dynamic approaches in those methods (if those have doctrine.reportDynamicQueryBuilders: true
).
Hey, I just merged the most important part of this PR: 5745ea6 Please let me know if I missed anything and open a new PR, thanks. |
One note here: are we sure |
If more hydratation modes are now supported, I believe all those getXxxResult calls should be added to platform test and verified that it matches. |
I dunno bout
But since the query is already considered as a Should revert most of the PR (HYDRATE_SCALAR / HYDRATE_SINGLE_SCALAR / HYDRATE_SCALAR_COLUMN) to only keep the HYDRATE_ARRAY inference (cc @ondrejmirtes) or do you see a way to improve the dbal inference @janedbal ? |
I'd need to dig deeper into it, but basically, for those hydratation modes you need to use |
I don't think we know the mode before because the order things are done for
That's why it may require to have something like
which is not really satisfying |
Yeah, that is not very nice. Btw, we are using only analysable methods since the query type inference was added and you actually dont need all the other methods. Everything can be replaced by the supported ones. We have this backed up by a rule. Thereotically, such rule can be even in phpstan-doctrine under some flag. |
So I'd say yes. |
I don't understand
Done #588 |
I'm just saying that codebase can still have 100% type coverage in terms of DQLs even when some of the methods are not supported:
and pass |
The main method i use was But yeah this can be avoided... |
Silly, but type-safe :) |
I have trouble to understand why we have a such different behavior with hydration mode. I created doctrine/orm#11527 to know more about it if you're interested. But I feel like you may already know the answer, or at least know way more things than me about this subject. |
If you look at |
Same as #453 (comment)
With the commit 1b0a1b0
I changed the strategy to be easily accepted and then easier to merge:
array<mixed>
=> This way we have the same behavior than before and people doesn't get error moving from level 9 to 7-8.