#19030: primary in model is not primary key in database
----------------------------------------------+--------------------
     Reporter:  ccruickshank                  |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.3
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 I've recently started using Django for a smallish project.
 At the moment I'm developing models but have noticed a possible bug

 A "primary key" created in the model is not a "primary key" in the
 Postgres db but "unique" is this a bug?

 The sqlall code suggest that it is attempting to create a tabel with the
 right structure, but the database shows the field to be "unique" and not
 "primary key"


 == Model info ==

 {{{
 from django.db import models

 # Create your models here.

 class ModelTest(models.Model):
     pkey=models.CharField(max_length=20, primary_key=True)
     ukey=models.CharField(max_length=20,unique=True)
 }}}

 == sqlall info ==
 {{{
 C:\dev\patinbox>python manage.py sqlall micropat_db
 BEGIN;
 CREATE TABLE "micropat_db_modeltest" (
     "pkey" varchar(20) NOT NULL PRIMARY KEY,
     "ukey" varchar(20) NOT NULL UNIQUE
 )
 ;
 }}}


 == extract from postgres database (version 9.1)==

 {{{
 -- Table: micropat_db_modeltest

 -- DROP TABLE micropat_db_modeltest;

 CREATE TABLE micropat_db_modeltest
 (
   pkey character varying(20) NOT NULL,
   ukey character varying(20) NOT NULL,
   CONSTRAINT micropat_db_modeltest_pkey_uniq UNIQUE (pkey ),
   CONSTRAINT micropat_db_modeltest_ukey_key UNIQUE (ukey )
 )
 WITH (
   OIDS=FALSE
 );
 ALTER TABLE micropat_db_modeltest
   OWNER TO postgres;
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/19030>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to