On 04/20/2013 01:42 PM, Barry Warsaw wrote:> On Apr 13, 2013, at 12:51 PM, 
Steven D'Aprano wrote:
>[...]
>>What's the justification for this [unique values] restriction? I have
>>looked in the PEP, and didn't see one.
> 
> If you allowed this, there would be no way to look up an enumeration item by
> value.  This is necessary for e.g. storing the value in a database.  If you
> know that the "insect" column is an INTEGER that represents an enumeration
> item of Insect, then you can just store the int value in the column.  To
> reconstitute the actual enumeration item when you read the column back from
> the database, you need to be able to look up the item by value.
>[...] 

Composite keys have been part of relational databases from
their inception.  If you want to store an enumeration value
in a database when non-unique values are possible, you can 
do so simply by storing the name, value pair; i.e. use two 
columns instead of one.  Of course this does not preclude 
storing just the value when you know they will be unique.
But it is not true that unique values are *required* for 
storing enumeration values in a database.

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to