On 11/11/2011 11:20 AM, Alex K wrote:
Thanks, but if I need allow nullable primary_keys it not works.
I tried:
user_id = db.Column(db.Integer, db.ForeignKey('user.id <http://user.id>', ondelete='SET NULL'), primary_key=True, nullable=True, server_default=text('NULL'))

A primary key can never be null. The PostgreSQL documentation describes this as follows: "Technically, a primary key constraint is simply a combination of a unique constraint and a not-null constraint.".

I suggest that you replace primary_key=True with unique=True.

Wichert.

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to