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.
vic
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
>> Is there a less ugly way to declare uniqueness constraints for the
>> following example?
>>
>> [snip, snip example...]
>>
>
> You can use the "using_table_options" statement for that.
>
FYI, I just added something about this to the FAQ. It might be a good
idea to start thinking about how to make the FAQ available on the
website, or we could follow through and put up a Wiki.
Any ideas?
--
Jonathan LaCour
http://cleverdevil.org
vic