Blog
Django ORM and Oracle notes
Behaviour that the documentation does not state, measured against a real database. Each note names the fault, the cause, and the repair.
Oracle
-
Why order_by() sorts 10 before 2 on Oracle
Oracle and MariaDB compare a value from a
JSONFieldas text. The filter stays correct, so a suite on SQLite passes. -
A Django JSON column on Oracle returns a LOB, not a string
A raw cursor gives back a handle, not text. The handle also reads one time only.
-
ORA-40478: a JSON value too long for a Django query on Oracle
Above 4000 characters a key read returns an empty string, and
filter()misses the row. Neither one reports a fault. -
ORA-02293 when a Django TextField becomes a JSONField on Oracle
Django adds
CHECK (col IS JSON). One old row of plain text stops the migration, and the error names no row. -
Django cuts table and index names to 30 characters on Oracle
Oracle 12.2 permits 128 characters. Django still reports 30, and the truncation is silent.
Migrations
-
How to undo a Django migration
Name the state to return to, not the migration to remove. A reverse of
AddFielddestroys the column. -
Why Django migrate says the table already exists
Four causes, and one repair that hides a column difference until the next deploy.