On 4/27/07, Victor Ng <[EMAIL PROTECTED]> wrote:
>
> Is there a less ugly way to declare uniqueness constraints for the
> following example?
>
> 6 class Bar(Entity):
> 7 has_field('id', Integer(), primary_key=True)
> 8
> 9 class Foo(Entity):
> 10 belongs_to('bar', of_kind='Bar')
> 11 has_field('id', Integer(), primary_key=True)
> 12 Foo._descriptor.add_constraint(UniqueConstraint('bar_id', 'id'))
>
> I read through my copy of the elixir source and I didn't see anywhere
> that the EntityMeta would pick up constraint declarations.
You can use the "using_table_options" statement for that.
Here is an excerpt from the TestTableOptions test in:
http://elixir.ematia.de/svn/elixir/trunk/tests/test_options.py
class Person(Entity):
has_field('firstname', Unicode(30))
has_field('surname', Unicode(30))
using_table_options(UniqueConstraint('firstname', 'surname'))
--
Gaƫtan de Menten
http://openhex.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"SQLElixir" 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 this group at
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---