sess.clear()
# assert result via direct get() of parent object
- # TODO: dual PK here is a temporary workaround until #185 is fixed again
- result = sess.query(parent_class).get([parent_obj.id, parent_obj.id])
+ result = sess.query(parent_class).get(parent_obj.id)
assert result.id == parent_obj.id
assert result.collection[0].id == child_obj.id
if direction == ONETOMANY:
assert result.collection[1].id == child2.id
elif direction == MANYTOONE:
- result2 = sess.query(parent_class).get([parent2.id, parent2.id])
+ result2 = sess.query(parent_class).get(parent2.id)
assert result2.id == parent2.id
assert result2.collection[0].id == child_obj.id
def test_implicit(self):
person_mapper = mapper(Person, person_table)
mapper(Employee, employee_table, inherits=person_mapper)
- print class_mapper(Employee).primary_key
- assert list(class_mapper(Employee).primary_key) == [person_table.c.id, employee_table.c.id]
- self._do_test(True)
+ try:
+ print class_mapper(Employee).primary_key
+ assert list(class_mapper(Employee).primary_key) == [person_table.c.id, employee_table.c.id]
+ assert False
+ except RuntimeWarning, e:
+ assert str(e) == "On mapper Mapper|Employee|employees, primary key column 'employees.id' is being combined with distinct primary key column 'persons.id' in attribute 'id'. Use explicit properties to give each column its own mapped attribute name."
def test_explicit_props(self):
person_mapper = mapper(Person, person_table)
def test_explicit_composite_pk(self):
person_mapper = mapper(Person, person_table)
mapper(Employee, employee_table, inherits=person_mapper, primary_key=[person_table.c.id, employee_table.c.id])
- self._do_test(True)
+ try:
+ self._do_test(True)
+ assert False
+ except RuntimeWarning, e:
+ assert str(e) == "On mapper Mapper|Employee|employees, primary key column 'employees.id' is being combined with distinct primary key column 'persons.id' in attribute 'id'. Use explicit properties to give each column its own mapped attribute name."
def test_explicit_pk(self):
person_mapper = mapper(Person, person_table)