Opened 16 years ago
Closed 13 years ago
#7783 closed Bug (fixed)
PostgreSQL database introspection does not detect NULL columns
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Core (Management commands) | Version: | dev |
Severity: | Normal | Keywords: | inspectdb |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
cursor.description does not return the null_ok field, so database introspection does not add null=True to column definitions. The is_nullable column in information_schema.columns does contain this information, however.
Attachments (3)
Change History (18)
by , 16 years ago
Attachment: | pgnulls.diff added |
---|
comment:2 by , 16 years ago
I am only using PostgreSQL 8.x, but I think information_schema was added in PostgreSQL 7.4:
http://www.postgresql.org/docs/7.4/static/information-schema.html
comment:3 by , 16 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
Accepted. Can someone confirm if/what versions of 7.x this works on?
comment:4 by , 14 years ago
Component: | django-admin.py inspectdb → Core (Management commands) |
---|
comment:5 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:6 by , 13 years ago
Easy pickings: | unset |
---|---|
UI/UX: | unset |
We tried to setup an environment using PostgreSQL 7.4.30 (the oldest one available for download)[1] to answer your question. Unfortunately when we run manage.py syncdb we received an error message stating that:
"django.db.utils.DatabaseError: function pg_get_serial_sequence("unknown", "unknown") does not exist"
Further research in the django-users mailing list revealed that version 7.4 of PostgreSQL does not contain the function pg_get_serial_sequence.[2] A reply from django core developer Russell Keith-Magee says that in Django version 1.3 support for PostgreSQL 7.4 was abandoned.[3]
[1]http://www.postgresql.org/ftp/source/
[2]http://markmail.org/thread/pf4bmphpsv6m4djl
[3]http://markmail.org/message/tp5czlz3ipy7vd5j
comment:7 by , 13 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:8 by , 13 years ago
Needs tests: | set |
---|
This can't be RFC, the patch doesn't even apply:
trunk % patch -p0 < ~/Downloads/pgnulls.diff patching file django/db/backends/postgresql_psycopg2/introspection.py Hunk #1 FAILED at 15. 1 out of 1 hunk FAILED -- saving rejects to file django/db/backends/postgresql_psycopg2/introspection.py.rej
comment:9 by , 13 years ago
Triage Stage: | Ready for checkin → Accepted |
---|
comment:10 by , 13 years ago
This patch is applied to which version? I have the same problem, but using django 1.3 and postgres_psycopg2 driver and this patch can not be applied, just like aaugustin have reported.
comment:12 by , 13 years ago
Keywords: | inspectdb added |
---|
comment:13 by , 13 years ago
Needs tests: | unset |
---|---|
Patch needs improvement: | unset |
comment:14 by , 13 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Patch to map the is_nullable column from information_schema to the null_ok item in cursor.description