#35018: Invalid SQL for GeneratedField on Oracle
-------------------------------------+-------------------------------------
Reporter: Václav | Owner: nobody
Řehák |
Type: Bug | Status: new
Component: Database | Version: 5.0
layer (models, ORM) |
Severity: Normal | Keywords: oracle
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I'm not sure this is actual bug or I am doing something wrong (please
point me to the doc if I missed one).
I am trying `GeneratedField` on Django 5.0 in a project running on Oracle
Database 19c Enterprise Edition, Version 19.18.0.0.0. My real use case is
bit more complicated so made up a simpler one - I have
`ts_password_changed` as `DateTimeField(blank=True, null=True)` and I'm
trying to add generated boolean field:
{{{
is_password_changed = GeneratedField(
expression=ExpressionWrapper(Q(ts_password_changed__isnull=False),
output_field=models.BooleanField()),
output_field=models.BooleanField(),
db_persist=False
)
}}}
The generated migration SQL looks like this:
{{{
ALTER TABLE "CORE_USER" ADD "IS_PASSWORD_CHANGED" NUMBER(1) GENERATED
ALWAYS AS ("TS_PASSWORD_CHANGED" IS NOT NULL) VIRTUAL;
}}}
and Oracle refuses it with
{{{
ORA-54016: Invalid column expression was specified, Position 81
}}}
However, it works when I modify the query to
{{{
ALTER TABLE "CORE_USER" ADD "IS_PASSWORD_CHANGED" NUMBER(1) GENERATED
ALWAYS AS (CASE WHEN "TS_PASSWORD_CHANGED" IS NOT NULL THEN 1 ELSE 0 END)
VIRTUAL;
}}}
which is probably what Django should be generating.
--
Ticket URL: <https://code.djangoproject.com/ticket/35018>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018c3e488f97-6468265e-58e1-494a-ac25-fe458baa3184-000000%40eu-central-1.amazonses.com.