how do you define composite primary key made up of 1 foreign key
(username, a text field from user table) and id field(integer field)
from post table?

can you have attribute based syntax and dsl based syntax together for
a model?  If I use attribute based syntax to declare ManyToOne(User)
field in model Post, that means it can only deal with integer id
field.

Here are my models:

# primary key for user model is a text field. (There is no integer id
field)
class User(Entity):
    using_options(tablename='user')
    username = Field(String(30),  primary_key = True, nullable =
False, unique=True)

class Post(Entity):
    using_options(tablename='post')
    # id and username( foreign key), are composite primary key for the
Post table
    id = Field(Integer, primary_key = True, autoincrement = True,
nullable = False)
    belongs_to('user', of_kind = 'User', inverse = 'post',
column_kwargs = {'primary_key': True, 'nullable': False})
    using_table_options(UniqueConstraint('id', 'user'))
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to