﻿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
35787	CharField migration with preserve_default=False keeps the DB default on Oracle	Václav Řehák		"I have a following migration:

{{{
migrations.AlterField(
    model_name=""account"",
    name=""aggregation_group"",
    field=models.CharField(
        blank=True,
        default="""",
        max_length=40,
    ),
    preserve_default=False,
)
}}}

for a `CharField` which was defined as `null=True` before. When I run `sqlmigrate` with Oracle backend, I get the following SQL:

{{{
ALTER TABLE ""CORE_ACCOUNT"" MODIFY ""AGGREGATION_GROUP"" DEFAULT '';
UPDATE ""CORE_ACCOUNT"" SET ""AGGREGATION_GROUP"" = '' WHERE ""AGGREGATION_GROUP"" IS NULL;
ALTER TABLE ""CORE_ACCOUNT"" MODIFY ""AGGREGATION_GROUP"" DEFAULT NULL;
}}}

Note the last command sets a DB default which I don't want.

When I run the same migration on Postgres backend, I get this SQL:
{{{
ALTER TABLE ""core_account"" ALTER COLUMN ""aggregation_group"" SET DEFAULT '';
UPDATE ""core_account"" SET ""aggregation_group"" = '' WHERE ""aggregation_group"" IS NULL; SET CONSTRAINTS ALL IMMEDIATE;
ALTER TABLE ""core_account"" ALTER COLUMN ""aggregation_group"" SET NOT NULL;
ALTER TABLE ""core_account"" ALTER COLUMN ""aggregation_group"" DROP DEFAULT;
}}}
with the default being properly dropped.
"	Bug	closed	Migrations	5.1	Normal	invalid	Oracle	Simon Charette Mariusz Felisiak	Unreviewed	0	0	0	0	0	0
