Comment (by Toan Vuong):
Thanks for the reply! I can work on a PR for the `PositiveIntegerField`
change following the patch you wrote.
However, regarding your statement:
> Coalesce() on Oracle checks the output_field of arguments and crashes
This seems incorrect, because using `Coalesce` alone would crash on both
Postgres and Oracle. The weird thing is if I have a `Case` on top of the
"bad" `Coalesce`, then only Oracle crashes. The Postgres queryset executes
successfully. So it seems like `Case` behaves differently between the
two, and probably incorrectly swallows the error thrown by `Coalesce` in
the Postgres scenario which also seems like a bug?
--
Ticket URL: <https://code.djangoproject.com/ticket/34858#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: nobody => Toan Vuong
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/34858#comment:5>
* has_patch: 0 => 1
Comment:
Opened a PR:
https://github.com/django/django/pull/17296
Still wondering about whether we need to do something about `Case` between
Postgres vs. Oracle, because the behavior still seems inconsistent there.
--
Ticket URL: <https://code.djangoproject.com/ticket/34858#comment:6>
Comment (by Mariusz Felisiak):
Replying to [comment:6 Toan Vuong]:
> Still wondering about whether we need to do something about `Case`
between Postgres vs. Oracle, because the behavior still seems inconsistent
there.
`Coalesce()` on Oracle
[https://github.com/django/django/blob/d7972436639bacada0f94d3b9818446343af59ad/django/db/models/functions/comparison.py#L93
explicitly checks] the `output_field` when it's compiled (for
`Cast.default)`, on other database the `output_field` is not used when
`Coalesce()` is compiled so it doesn't crash. The crash on Oracle is a
side-effect of the current implementation, IMO, there is no need to change
it.
> Edit: Also not sure what the process is to open PRs for other
branches(?). Seems like I should also merge this to main and stable/5.0.x?
Mergers will backport if needed.
--
Ticket URL: <https://code.djangoproject.com/ticket/34858#comment:7>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/34858#comment:8>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"4de31ec680df062e5964b630f1b881ead5004e15" 4de31ec]:
{{{
#!CommitTicketReference repository=""
revision="4de31ec680df062e5964b630f1b881ead5004e15"
Fixed #34858 -- Corrected resolving output_field for PositiveIntegerField.
Regression in 40b8a6174f001a310aa33f7880db0efeeb04d4c4.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34858#comment:9>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"dcd3a0316bed8605c0464793cd7ca73027eaa780" dcd3a03]:
{{{
#!CommitTicketReference repository=""
revision="dcd3a0316bed8605c0464793cd7ca73027eaa780"
[5.0.x] Fixed #34858 -- Corrected resolving output_field for
PositiveIntegerField.
Regression in 40b8a6174f001a310aa33f7880db0efeeb04d4c4.
Backport of 4de31ec680df062e5964b630f1b881ead5004e15 from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34858#comment:10>
Comment (by Toan Vuong):
> Coalesce() on Oracle explicitly checks the output_field when it's
compiled (for Cast.default), on other database the output_field is not
used when Coalesce() is compiled so it doesn't crash. The crash on Oracle
is a side-effect of the current implementation, IMO, there is no need to
change it.
Thanks, this is what I was missing. In our local copy of Django I
essentially added a try/catch on that `as_oracle` function which worked,
but I didn't realize that was only called in some cases but not others.
--
Ticket URL: <https://code.djangoproject.com/ticket/34858#comment:11>