﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35018	GeneratedField crashes on Oracle 19c when output_field is BooleanField.	Václav Řehák	Mariusz Felisiak	"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.
"	Bug	closed	Database layer (models, ORM)	5.0	Release blocker	fixed	oracle	Lily Foote Jeremy Nauta	Accepted	1	0	0	0	0	0
