Opened 5 years ago

Closed 4 years ago

#14107 closed (invalid)

Problem with non-null fieds using Oracle Backend

Reported by: mdpetry Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Hi,

I have a problem with Oracle Backend when I generate the SQL script to build the database structure

Some fields (I don't know why :P) didn't set the "NOT NULL" attribute on SQL scripts for Oracle Database, for PostgreSQL database work fine. Even if I set the Blank and Null attributes to false in my models.py

Here is a snippet of my models.py: http://dpaste.org/ovwp/

and here, the Oracle SQL Script: http://dpaste.org/fwnq/

and PostgreSQL script: http://dpaste.org/kYEN/

Change History (3)

comment:1 Changed 5 years ago by mdpetry

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 in reply to: ↑ description ; follow-up: Changed 5 years ago by mdpetry

Sorry, I posted a sqlite script instead of postgresql script, here is the right scripts:

PostgreSQL: http://dpaste.org/CrYw/

SQLite http://dpaste.org/Ybf7/

Replying to mdpetry:

Hi,

I have a problem with Oracle Backend when I generate the SQL script to build the database structure

Some fields (I don't know why :P) didn't set the "NOT NULL" attribute on SQL scripts for Oracle Database, for PostgreSQL database work fine. Even if I set the Blank and Null attributes to false in my models.py

Here is a snippet of my models.py: http://dpaste.org/ovwp/

and here, the Oracle SQL Script: http://dpaste.org/fwnq/

and PostgreSQL script: http://dpaste.org/kYEN/

comment:3 in reply to: ↑ 2 Changed 4 years ago by ikelly

  • Resolution set to invalid
  • Status changed from new to closed

This is intended behavior, as noted in the docs:

When using the Oracle database backend, the null=True option will be coerced for string-based fields that have the empty string as a possible value, and the value NULL will be stored to denote the empty string.

This is because Oracle treats the empty string and NULL as the same thing, and a CharField can be used to store the empty string even with null=True, blank=True. If you really want the column to be NOT NULL, you need to set it manually.

Note: See TracTickets for help on using tickets.
Back to Top