試圖以這種方式來使用sqlalchemy.schema.CheckConstraint:的SQLAlchemy:CheckConstraint與字符串函數
themes2tags_table = Table('themes2tags', Base.metadata,
Column('theme_id', String(32), ForeignKey('tags.id')),
Column('tag_id', String(32), ForeignKey('tags.id')),
PrimaryKeyConstraint(['theme_id', 'tag_id']),
CheckConstraint("substr(theme_id,1,1)='3'"))
(意味着許多一對多在標籤表和主題是與預定義前綴的標籤自我指涉的關係,顯然),結果是什麼
...CheckConstraint("substr(theme_id,1,1)='3'")
File "build\bdist.win32\egg\sqlalchemy\schema.py", line 303, in __new__
File "build\bdist.win32\egg\sqlalchemy\schema.py", line 370, in _init
File "build\bdist.win32\egg\sqlalchemy\schema.py", line 64, in _init_items
File "build\bdist.win32\egg\sqlalchemy\events.py", line 234, in _set_parent_wi
th_dispatch
File "build\bdist.win32\egg\sqlalchemy\schema.py", line 2133, in _set_parent
File "build\bdist.win32\egg\sqlalchemy\schema.py", line 1909, in _set_parent
File "build\bdist.win32\egg\sqlalchemy\schema.py", line 1883, in _set_parent
File "build\bdist.win32\egg\sqlalchemy\sql\expression.py", line 2213, in add
AttributeError: 'list' object has no attribute 'key'
我在哪裏錯了?在這種情況下是否有這樣的限制?
當前後端是sqlite,但我考慮將來遷移到Postgres,因此尋找更少的通用收據。
UPD:SQLAlchemy的0.7.5
這是什麼版本的SQLAlchemy?無論如何,這不是0.7.8。 – 2012-07-31 09:03:05