Patches item #1181657, was opened at 2005-04-12 21:40
Message generated for change (Settings changed) made by phd
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1181657&group_id=74338
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
>Resolution: Rejected
Priority: 5
Submitted By: David M. Cook (daverz)
Assigned to: Nobody/Anonymous (nobody)
Summary: Direct support for UNIQUE table constraint
Initial Comment:
This is a patch to provide direct support for UNIQUE
table constraints by marking each column in the
constraint with uniqueKey=True. I stole the idea from
hibernate (actually in hibernate you specify a
constraint name, so you can have multiple unique
constraints per table; this is just a first pass at the
idea and a RFC).
class Foo(SQLObject):
baz = StringCol(uniqueKey=True)
quux = StringCol(uniqueKey=True)
would produce
CREATE TABLE foo (
id INTEGER PRIMARY KEY,
quux TEXT,
baz TEXT,
UNIQUE(quux, baz)
);
Right now you can get the same practical effect with a
unique index, but this provides direct semantic (or is
it syntactic? I get them confused) support for unique
table constraints, and lets the database decide how it
will enforce the constraint.
I think all the supported DBs support UNIQUE table
constraints, I haven't checked yet. I'll try to come
up with some test cases later.
----------------------------------------------------------------------
Comment By: Oleg Broytmann (phd)
Date: 2005-09-13 16:58
Message:
Logged In: YES
user_id=4799
Then close the patch, please.
----------------------------------------------------------------------
Comment By: David M. Cook (daverz)
Date: 2005-04-13 05:10
Message:
Logged In: YES
user_id=668544
Eh, after implementing this, even allowing multiple
constraints per column, my enthusiasm has cooled. It's
redundant, and I think doing it with unique indexes actually
makes the intent clearer, e.g.
c1 = DatabaseIndex('bar', 'baz', unique=True)
c2 = DatabaseIndex('bar', 'quux', unique=True)
vs.
bar = StringCol(uniqueKey=('c1', 'c2'))
baz = StringCol(uniqueKey='c1')
quux = StringCol(uniqueKey='c2')
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1181657&group_id=74338
|