Changeset 534 for elixir/trunk
- Timestamp:
- 01/29/11 20:53:10 (16 months ago)
- Location:
- elixir/trunk
- Files:
-
- 3 modified
-
CHANGES (modified) (1 diff)
-
elixir/entity.py (modified) (2 diffs)
-
tests/test_inherit.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
elixir/trunk/CHANGES
r528 r534 12 12 Bug fixes: 13 13 - Fixed a few tests to work on SA 0.6.x 14 - Fixed bad foreign key constraint generated for classes inheriting from a 15 class with multiple primary keys when using the "multi" inheritance. 16 Patch from & closes #114. 14 17 15 18 0.7.1 - 2009-11-16 -
elixir/trunk/elixir/entity.py
r532 r534 199 199 tablename = parent_desc.table_fullname 200 200 join_clauses = [] 201 fk_columns = [] 201 202 for pk_col in parent_desc.primary_keys: 202 203 colname = options.MULTIINHERITANCECOL_NAMEFORMAT % \ … … 208 209 # attached to a table 209 210 pk_col_name = "%s.%s" % (tablename, pk_col.key) 210 fk = ForeignKey(pk_col_name, ondelete='cascade') 211 col = Column(colname, pk_col.type, fk, 212 primary_key=True) 211 col = Column(colname, pk_col.type, primary_key=True) 212 fk_columns.append(col) 213 213 self.add_column(col) 214 214 join_clauses.append(col == pk_col) 215 215 self.join_condition = and_(*join_clauses) 216 self.add_constraint( 217 ForeignKeyConstraint(fk_columns, 218 parent_desc.primary_keys, ondelete='CASCADE')) 216 219 elif self.inheritance == 'concrete': 217 220 # Copy primary key columns from the parent. -
elixir/trunk/tests/test_inherit.py
r490 r534 8 8 def setup(): 9 9 metadata.bind = 'sqlite://' 10 # metadata.bind = 'postgres ://@/test'10 # metadata.bind = 'postgresql://@/test' 11 11 # metadata.bind.echo = True 12 12 elixir.options_defaults['shortnames'] = True … … 144 144 setup_all() 145 145 146 def test_multi_pk(self): 147 class A(Entity): 148 using_options(inheritance='multi') 149 firstname = Field(String(50), primary_key=True) 150 lastname = Field(String(50), primary_key=True) 151 152 class B(A): 153 using_options(inheritance='multi') 154 155 setup_all(True) 156 157 b1 = B(firstname='1', lastname='b') 158 b2 = B(firstname='2', lastname='b') 159 160 session.commit() 161 162 b1.delete() 163 164 session.commit() 165 166 assert len(B.query.all()) == 1 167 146 168 def test_multitable_polymorphic_load(self): 147 169 class A(Entity):
