-
Notifications
You must be signed in to change notification settings - Fork 98
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
Use benevolent union for scalar in queries #447
Conversation
1dbf6fd
to
b4c3152
Compare
Hi, I need tests to understand what will this fix :) I'd say we need benevolent union even for the case without |
I added benevolent union in two situations so far:
I updated the tests (about int|numeric-string) and added one test about where conditions @ondrejmirtes. |
0e7b673
to
86e52ac
Compare
Does this solution seems ok to you @ondrejmirtes ? This should avoid false positive from #412 but still be an improvement of query results. And possibly allow you to make new releases, unless you find others issues. :) |
FYI I had to revert some of your commits so I can release phpstan-doctrine with other changes. Unfortunately I currently cannot give this the work priority and the needed timeframe of multiple days in order to finish this. 84bf895...f1499e5 |
I understand. I recreated the PR with the commits reverted #453 then |
This PR could be an idea of solution for #446
I assume that before #412, the resultType of Query were less used a lot so we didn't have a lot of feedback about the type resolution. But I tried to reproduce your "bug", and even the merge of my PR
were reporting
list<array{id: int|numeric-string|null}>
. I just give the same result withgetArrayResult
now.For Identity, I found some specific solution to improve the return type,
but still, I anticipate a lot of similar issue with results like
which is reported as
list<array{id: int|null}>
when we would expectlist<array{id: int}>
. Notice that in the same way, before #412, the query was already returninglist<array{id: int|null}>
forgetResult
calls.Since we currently cannot be sure that all those
|null
are true because, for example, we don't check theWHERE
condition (and this would be complex). I think the best solution so far would be to use BenevolentUnion for this instead of default unions.Before fixing the tests I'd like your opinion on such change.