summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/aaa_profiling/test_memusage.py10
-rw-r--r--test/aaa_profiling/test_orm.py4
-rw-r--r--test/dialect/test_postgresql.py2
-rw-r--r--test/ext/test_associationproxy.py30
-rw-r--r--test/ext/test_declarative.py78
-rw-r--r--test/ext/test_orderinglist.py4
-rw-r--r--test/ext/test_serializer.py4
-rw-r--r--test/orm/inheritance/test_abc_inheritance.py6
-rw-r--r--test/orm/inheritance/test_basic.py28
-rw-r--r--test/orm/inheritance/test_concrete.py26
-rw-r--r--test/orm/inheritance/test_magazine.py16
-rw-r--r--test/orm/inheritance/test_manytomany.py10
-rw-r--r--test/orm/inheritance/test_poly_linked_list.py12
-rw-r--r--test/orm/inheritance/test_polymorph.py30
-rw-r--r--test/orm/inheritance/test_polymorph2.py72
-rw-r--r--test/orm/inheritance/test_productspec.py20
-rw-r--r--test/orm/inheritance/test_query.py38
-rw-r--r--test/orm/inheritance/test_single.py14
-rw-r--r--test/orm/sharding/test_shard.py2
-rw-r--r--test/orm/test_association.py6
-rw-r--r--test/orm/test_assorted_eager.py50
-rw-r--r--test/orm/test_backref_mutations.py12
-rw-r--r--test/orm/test_cascade.py86
-rw-r--r--test/orm/test_collection.py22
-rw-r--r--test/orm/test_compile.py18
-rw-r--r--test/orm/test_cycles.py66
-rw-r--r--test/orm/test_defaults.py2
-rw-r--r--test/orm/test_deprecations.py5
-rw-r--r--test/orm/test_dynamic.py14
-rw-r--r--test/orm/test_eager_relations.py160
-rw-r--r--test/orm/test_expire.py50
-rw-r--r--test/orm/test_generative.py8
-rw-r--r--test/orm/test_instrumentation.py8
-rw-r--r--test/orm/test_lazy_relations.py56
-rw-r--r--test/orm/test_lazytest1.py10
-rw-r--r--test/orm/test_manytomany.py32
-rw-r--r--test/orm/test_mapper.py130
-rw-r--r--test/orm/test_merge.py48
-rw-r--r--test/orm/test_naturalpks.py26
-rw-r--r--test/orm/test_onetoone.py4
-rw-r--r--test/orm/test_pickled.py20
-rw-r--r--test/orm/test_query.py82
-rw-r--r--test/orm/test_relationships.py313
-rw-r--r--test/orm/test_scoping.py6
-rw-r--r--test/orm/test_session.py24
-rw-r--r--test/orm/test_transaction.py2
-rw-r--r--test/orm/test_unitofwork.py88
-rw-r--r--test/orm/test_versioning.py6
-rw-r--r--test/perf/cascade_speed.py6
-rw-r--r--test/perf/masseagerload.py2
-rw-r--r--test/perf/massload2.py12
-rw-r--r--test/perf/objupdatespeed.py2
-rw-r--r--test/perf/ormsession.py6
-rw-r--r--test/perf/sessions.py2
-rw-r--r--test/perf/threaded_compile.py2
-rw-r--r--test/zblog/mappers.py18
56 files changed, 933 insertions, 877 deletions
diff --git a/test/aaa_profiling/test_memusage.py b/test/aaa_profiling/test_memusage.py
index 057adb06a..ba1f67ddf 100644
--- a/test/aaa_profiling/test_memusage.py
+++ b/test/aaa_profiling/test_memusage.py
@@ -1,5 +1,5 @@
from sqlalchemy.test.testing import eq_
-from sqlalchemy.orm import mapper, relation, create_session, clear_mappers, sessionmaker
+from sqlalchemy.orm import mapper, relationship, create_session, clear_mappers, sessionmaker
from sqlalchemy.orm.mapper import _mapper_registry
from sqlalchemy.orm.session import _sessions
from sqlalchemy.util import jython
@@ -92,7 +92,7 @@ class MemUsageTest(EnsureZeroed):
metadata.create_all()
m1 = mapper(A, table1, properties={
- "bs":relation(B, cascade="all, delete", order_by=table2.c.col1)},
+ "bs":relationship(B, cascade="all, delete", order_by=table2.c.col1)},
order_by=table1.c.col1)
m2 = mapper(B, table2)
@@ -145,7 +145,7 @@ class MemUsageTest(EnsureZeroed):
@profile_memory
def go():
m1 = mapper(A, table1, properties={
- "bs":relation(B, order_by=table2.c.col1)
+ "bs":relationship(B, order_by=table2.c.col1)
})
m2 = mapper(B, table2)
@@ -271,7 +271,7 @@ class MemUsageTest(EnsureZeroed):
pass
mapper(A, table1, properties={
- 'bs':relation(B, secondary=table3, backref='as', order_by=table3.c.t1)
+ 'bs':relationship(B, secondary=table3, backref='as', order_by=table3.c.t1)
})
mapper(B, table2)
@@ -336,7 +336,7 @@ class MemUsageTest(EnsureZeroed):
pass
mapper(Foo, table1, properties={
- 'bars':relation(mapper(Bar, table2))
+ 'bars':relationship(mapper(Bar, table2))
})
metadata.create_all()
diff --git a/test/aaa_profiling/test_orm.py b/test/aaa_profiling/test_orm.py
index 8144415ef..0395cb92d 100644
--- a/test/aaa_profiling/test_orm.py
+++ b/test/aaa_profiling/test_orm.py
@@ -1,6 +1,6 @@
from sqlalchemy.test.testing import eq_, assert_raises, assert_raises_message
from sqlalchemy import exc as sa_exc, util, Integer, String, ForeignKey
-from sqlalchemy.orm import exc as orm_exc, mapper, relation, sessionmaker
+from sqlalchemy.orm import exc as orm_exc, mapper, relationship, sessionmaker
from sqlalchemy.test import testing, profiling
from test.orm import _base
@@ -33,7 +33,7 @@ class MergeTest(_base.MappedTest):
@testing.resolve_artifact_names
def setup_mappers(cls):
mapper(Parent, parent, properties={
- 'children':relation(Child, backref='parent')
+ 'children':relationship(Child, backref='parent')
})
mapper(Child, child)
diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py
index 8358825c4..472b12e50 100644
--- a/test/dialect/test_postgresql.py
+++ b/test/dialect/test_postgresql.py
@@ -436,7 +436,7 @@ class InsertTest(TestBase, AssertsExecutionResults):
# want to ensure that
# "null value in column "id" violates not-null constraint" is raised (IntegrityError on psycoopg2,
# but ProgrammingError on pg8000),
- # and not "ProgrammingError: (ProgrammingError) relation "t2_id_seq" does not exist".
+ # and not "ProgrammingError: (ProgrammingError) relationship "t2_id_seq" does not exist".
# the latter corresponds to autoincrement behavior, which is not the case
# here due to the foreign key.
for eng in [
diff --git a/test/ext/test_associationproxy.py b/test/ext/test_associationproxy.py
index 38a75814b..ea1864c92 100644
--- a/test/ext/test_associationproxy.py
+++ b/test/ext/test_associationproxy.py
@@ -91,7 +91,7 @@ class _CollectionOperations(TestBase):
self.name = name
mapper(Parent, parents_table, properties={
- '_children': relation(Child, lazy=False,
+ '_children': relationship(Child, lazy=False,
collection_class=collection_class)})
mapper(Child, children_table)
@@ -654,7 +654,7 @@ class ProxyFactoryTest(ListTest):
self.name = name
mapper(Parent, parents_table, properties={
- '_children': relation(Child, lazy=False,
+ '_children': relationship(Child, lazy=False,
collection_class=list)})
mapper(Child, children_table)
@@ -701,7 +701,7 @@ class ScalarTest(TestBase):
setattr(self, attr, kw[attr])
mapper(Parent, parents_table, properties={
- 'child': relation(Child, lazy=False,
+ 'child': relationship(Child, lazy=False,
backref='parent', uselist=False)})
mapper(Child, children_table)
@@ -836,7 +836,7 @@ class LazyLoadTest(TestBase):
Parent, Child = self.Parent, self.Child
mapper(Parent, self.table, properties={
- '_children': relation(Child, lazy=True,
+ '_children': relationship(Child, lazy=True,
collection_class=list)})
p = Parent('p')
@@ -854,7 +854,7 @@ class LazyLoadTest(TestBase):
Parent, Child = self.Parent, self.Child
mapper(Parent, self.table, properties={
- '_children': relation(Child, lazy=False,
+ '_children': relationship(Child, lazy=False,
collection_class=list)})
p = Parent('p')
@@ -869,7 +869,7 @@ class LazyLoadTest(TestBase):
Parent, Child = self.Parent, self.Child
mapper(Parent, self.table, properties={
- '_children': relation(Child, lazy=True, uselist=False)})
+ '_children': relationship(Child, lazy=True, uselist=False)})
p = Parent('p')
@@ -884,7 +884,7 @@ class LazyLoadTest(TestBase):
Parent, Child = self.Parent, self.Child
mapper(Parent, self.table, properties={
- '_children': relation(Child, lazy=False, uselist=False)})
+ '_children': relationship(Child, lazy=False, uselist=False)})
p = Parent('p')
@@ -921,7 +921,7 @@ class ReconstitutionTest(TestBase):
clear_mappers()
def test_weak_identity_map(self):
- mapper(Parent, self.parents, properties=dict(children=relation(Child)))
+ mapper(Parent, self.parents, properties=dict(children=relationship(Child)))
mapper(Child, self.children)
session = create_session(weak_identity_map=True)
@@ -941,7 +941,7 @@ class ReconstitutionTest(TestBase):
assert set(p.kids) == set(['c1', 'c2']), p.kids
def test_copy(self):
- mapper(Parent, self.parents, properties=dict(children=relation(Child)))
+ mapper(Parent, self.parents, properties=dict(children=relationship(Child)))
mapper(Child, self.children)
p = Parent('p1')
@@ -953,7 +953,7 @@ class ReconstitutionTest(TestBase):
assert set(p_copy.kids) == set(['c1', 'c2']), p.kids
def test_pickle_list(self):
- mapper(Parent, self.parents, properties=dict(children=relation(Child)))
+ mapper(Parent, self.parents, properties=dict(children=relationship(Child)))
mapper(Child, self.children)
p = Parent('p1')
@@ -966,7 +966,7 @@ class ReconstitutionTest(TestBase):
assert r2 == ['c1', 'c2']
def test_pickle_set(self):
- mapper(Parent, self.parents, properties=dict(children=relation(Child, collection_class=set)))
+ mapper(Parent, self.parents, properties=dict(children=relationship(Child, collection_class=set)))
mapper(Child, self.children)
p = Parent('p1')
@@ -980,7 +980,7 @@ class ReconstitutionTest(TestBase):
def test_pickle_dict(self):
mapper(Parent, self.parents, properties=dict(
- children=relation(KVChild, collection_class=collections.mapped_collection(PickleKeyFunc('name')))
+ children=relationship(KVChild, collection_class=collections.mapped_collection(PickleKeyFunc('name')))
))
mapper(KVChild, self.children)
@@ -1049,11 +1049,11 @@ class ComparatorTest(_base.MappedTest):
mapper(User, users)
mapper(Keyword, keywords, properties={
- 'user_keyword': relation(UserKeyword, uselist=False)
+ 'user_keyword': relationship(UserKeyword, uselist=False)
})
mapper(UserKeyword, userkeywords, properties={
- 'user': relation(User, backref='user_keywords'),
- 'keyword': relation(Keyword),
+ 'user': relationship(User, backref='user_keywords'),
+ 'keyword': relationship(Keyword),
})
@classmethod
diff --git a/test/ext/test_declarative.py b/test/ext/test_declarative.py
index 3642adeac..69b8848e9 100644
--- a/test/ext/test_declarative.py
+++ b/test/ext/test_declarative.py
@@ -6,7 +6,7 @@ import sqlalchemy as sa
from sqlalchemy.test import testing
from sqlalchemy import MetaData, Integer, String, ForeignKey, ForeignKeyConstraint, asc, Index
from sqlalchemy.test.schema import Table, Column
-from sqlalchemy.orm import relation, create_session, class_mapper, eagerload, compile_mappers, backref, clear_mappers, polymorphic_union, deferred
+from sqlalchemy.orm import relationship, create_session, class_mapper, eagerload, compile_mappers, backref, clear_mappers, polymorphic_union, deferred
from sqlalchemy.test.testing import eq_
from sqlalchemy.util import classproperty
@@ -28,7 +28,7 @@ class DeclarativeTest(DeclarativeTestBase):
id = Column('id', Integer, primary_key=True, test_needs_autoincrement=True)
name = Column('name', String(50))
- addresses = relation("Address", backref="user")
+ addresses = relationship("Address", backref="user")
class Address(Base, ComparableEntity):
__tablename__ = 'addresses'
@@ -113,7 +113,7 @@ class DeclarativeTest(DeclarativeTestBase):
id = Column('id', Integer, primary_key=True)
email = Column('email', String(50))
user_id = Column('user_id', Integer, ForeignKey('users.id'))
- user = relation("User", primaryjoin=user_id == User.id,
+ user = relationship("User", primaryjoin=user_id == User.id,
backref="addresses")
assert mapperlib._new_mappers is True
@@ -128,7 +128,7 @@ class DeclarativeTest(DeclarativeTestBase):
__tablename__ = 'users'
id = Column(Integer, primary_key=True, test_needs_autoincrement=True)
name = Column(String(50))
- addresses = relation("Address", order_by="desc(Address.email)",
+ addresses = relationship("Address", order_by="desc(Address.email)",
primaryjoin="User.id==Address.user_id", foreign_keys="[Address.user_id]",
backref=backref('user', primaryjoin="User.id==Address.user_id", foreign_keys="[Address.user_id]")
)
@@ -153,7 +153,7 @@ class DeclarativeTest(DeclarativeTestBase):
class Foo(Base, ComparableEntity):
__tablename__ = 'foo'
id = Column(Integer, primary_key=True)
- rel = relation("User", primaryjoin="User.addresses==Foo.id")
+ rel = relationship("User", primaryjoin="User.addresses==Foo.id")
assert_raises_message(exc.InvalidRequestError, "'addresses' is not an instance of ColumnProperty", compile_mappers)
def test_string_dependency_resolution_no_magic(self):
@@ -162,7 +162,7 @@ class DeclarativeTest(DeclarativeTestBase):
class User(Base, ComparableEntity):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
- addresses = relation("Address",
+ addresses = relationship("Address",
primaryjoin="User.id==Address.user_id.prop.columns[0]")
class Address(Base, ComparableEntity):
@@ -180,7 +180,7 @@ class DeclarativeTest(DeclarativeTestBase):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
name = Column(String(50))
- addresses = relation("Address",
+ addresses = relationship("Address",
primaryjoin="User.id==Address.user_id",
backref="user"
)
@@ -200,7 +200,7 @@ class DeclarativeTest(DeclarativeTestBase):
id = Column(Integer, primary_key=True)
name = Column(String(50))
- props = relation("Prop",
+ props = relationship("Prop",
secondary="user_to_prop",
primaryjoin="User.id==user_to_prop.c.user_id",
secondaryjoin="user_to_prop.c.prop_id==Prop.id",
@@ -219,7 +219,7 @@ class DeclarativeTest(DeclarativeTestBase):
compile_mappers()
assert class_mapper(User).get_property("props").secondary is user_to_prop
- def test_uncompiled_attributes_in_relation(self):
+ def test_uncompiled_attributes_in_relationship(self):
class Address(Base, ComparableEntity):
__tablename__ = 'addresses'
id = Column(Integer, primary_key=True, test_needs_autoincrement=True)
@@ -230,13 +230,13 @@ class DeclarativeTest(DeclarativeTestBase):
__tablename__ = 'users'
id = Column(Integer, primary_key=True, test_needs_autoincrement=True)
name = Column(String(50))
- addresses = relation("Address", order_by=Address.email,
+ addresses = relationship("Address", order_by=Address.email,
foreign_keys=Address.user_id,
remote_side=Address.user_id,
)
# get the mapper for User. User mapper will compile,
- # "addresses" relation will call upon Address.user_id for
+ # "addresses" relationship will call upon Address.user_id for
# its clause element. Address.user_id is a _CompileOnAttr,
# which then calls class_mapper(Address). But ! We're already
# "in compilation", but class_mapper(Address) needs to initialize
@@ -259,7 +259,7 @@ class DeclarativeTest(DeclarativeTestBase):
class User(Base):
__tablename__ = 'users'
id = Column('id', Integer, primary_key=True)
- addresses = relation("Address")
+ addresses = relationship("Address")
class Address(Base):
__tablename__ = 'addresses'
@@ -275,7 +275,7 @@ class DeclarativeTest(DeclarativeTestBase):
class User(Base):
__tablename__ = 'users'
id = Column('id', Integer, primary_key=True)
- addresses = relation("Addresss")
+ addresses = relationship("Addresss")
# hasattr() on a compile-loaded attribute
hasattr(User.addresses, 'property')
@@ -302,7 +302,7 @@ class DeclarativeTest(DeclarativeTestBase):
__tablename__ = 'detail'
id = Column(Integer, primary_key=True, test_needs_autoincrement=True)
master_id = Column(None, ForeignKey(Master.id))
- master = relation(Master)
+ master = relationship(Master)
Base.metadata.create_all()
@@ -327,11 +327,11 @@ class DeclarativeTest(DeclarativeTestBase):
__tablename__ = 'users'
id = Column('id', Integer, primary_key=True)
name = Column('name', String(50))
- error = relation("Address")
+ error = relationship("Address")
i = Index('my_index', User.name)
- # compile fails due to the nonexistent Addresses relation
+ # compile fails due to the nonexistent Addresses relationship
assert_raises(sa.exc.InvalidRequestError, compile_mappers)
# index configured
@@ -348,7 +348,7 @@ class DeclarativeTest(DeclarativeTestBase):
id = Column('id', Integer, primary_key=True, test_needs_autoincrement=True)
User.name = Column('name', String(50))
- User.addresses = relation("Address", backref="user")
+ User.addresses = relationship("Address", backref="user")
class Address(Base, ComparableEntity):
__tablename__ = 'addresses'
@@ -395,7 +395,7 @@ class DeclarativeTest(DeclarativeTestBase):
id = Column('id', Integer, primary_key=True, test_needs_autoincrement=True)
name = Column('name', String(50))
- addresses = relation("Address", order_by=Address.email)
+ addresses = relationship("Address", order_by=Address.email)
Base.metadata.create_all()
u1 = User(name='u1', addresses=[
@@ -424,7 +424,7 @@ class DeclarativeTest(DeclarativeTestBase):
id = Column('id', Integer, primary_key=True, test_needs_autoincrement=True)
name = Column('name', String(50))
- addresses = relation("Address", order_by=(Address.email, Address.id))
+ addresses = relationship("Address", order_by=(Address.email, Address.id))
Base.metadata.create_all()
u1 = User(name='u1', addresses=[
@@ -444,7 +444,7 @@ class DeclarativeTest(DeclarativeTestBase):
id = Column('id', Integer, primary_key=True, test_needs_autoincrement=True)
name = Column('name', String(50))
- addresses = relation("Address", backref="user")
+ addresses = relationship("Address", backref="user")
class Address(ComparableEntity):
__tablename__ = 'addresses'
@@ -554,7 +554,7 @@ class DeclarativeTest(DeclarativeTestBase):
id = Column('id', Integer, primary_key=True, test_needs_autoincrement=True)
name = Column('name', String(50))
- addresses = relation("Address", backref="user")
+ addresses = relationship("Address", backref="user")
class Address(Base, ComparableEntity):
__tablename__ = 'addresses'
@@ -621,7 +621,7 @@ class DeclarativeTest(DeclarativeTestBase):
adr_count = sa.orm.column_property(
sa.select([sa.func.count(Address.id)], Address.user_id == id).
as_scalar())
- addresses = relation(Address)
+ addresses = relationship(Address)
Base.metadata.create_all()
@@ -750,7 +750,7 @@ class DeclarativeTest(DeclarativeTestBase):
id = Column('id', Integer, primary_key=True, test_needs_autoincrement=True)
name = Column('name', String(50))
- addresses = relation("Address", backref="user")
+ addresses = relationship("Address", backref="user")
class Address(Base, ComparableEntity):
__tablename__ = 'addresses'
@@ -781,7 +781,7 @@ class DeclarativeTest(DeclarativeTestBase):
Address(email='two'),
])])
- def test_relation_reference(self):
+ def test_relationship_reference(self):
class Address(Base, ComparableEntity):
__tablename__ = 'addresses'
@@ -794,7 +794,7 @@ class DeclarativeTest(DeclarativeTestBase):
id = Column('id', Integer, primary_key=True, test_needs_autoincrement=True)
name = Column('name', String(50))
- addresses = relation("Address", backref="user",
+ addresses = relationship("Address", backref="user",
primaryjoin=id == Address.user_id)
User.address_count = sa.orm.column_property(
@@ -828,7 +828,7 @@ class DeclarativeTest(DeclarativeTestBase):
__tablename__ = 'foo'
id = sa.Column(sa.Integer, primary_key=True)
- bars = sa.orm.relation(Bar)
+ bars = sa.orm.relationship(Bar)
assert Bar.__mapper__.primary_key[0] is Bar.__table__.c.id
assert Bar.__mapper__.primary_key[1] is Bar.__table__.c.ex
@@ -952,7 +952,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase):
__tablename__ = 'companies'
id = Column('id', Integer, primary_key=True, test_needs_autoincrement=True)
name = Column('name', String(50))
- employees = relation("Person")
+ employees = relationship("Person")
class Person(Base, ComparableEntity):
__tablename__ = 'people'
@@ -1153,7 +1153,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase):
__tablename__ = 'companies'
id = Column('id', Integer, primary_key=True, test_needs_autoincrement=True)
name = Column('name', String(50))
- employees = relation("Person")
+ employees = relationship("Person")
class Person(Base, ComparableEntity):
__tablename__ = 'people'
@@ -1209,7 +1209,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase):
__tablename__ = 'companies'
id = Column('id', Integer, primary_key=True, test_needs_autoincrement=True)
name = Column('name', String(50))
- employees = relation("Person")
+ employees = relationship("Person")
class Person(Base, ComparableEntity):
__tablename__ = 'people'
@@ -1279,7 +1279,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase):
__tablename__ = 'companies'
id = Column('id', Integer, primary_key=True, test_needs_autoincrement=True)
name = Column('name', String(50))
- employees = relation("Person")
+ employees = relationship("Person")
class Person(Base, ComparableEntity):
__tablename__ = 'people'
@@ -1377,7 +1377,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase):
class Engineer(Person):
__mapper_args__ = {'polymorphic_identity':'engineer'}
primary_language_id = Column(Integer, ForeignKey('languages.id'))
- primary_language = relation("Language")
+ primary_language = relationship("Language")
class Language(Base, ComparableEntity):
__tablename__ = 'languages'
@@ -1595,16 +1595,16 @@ def _produce_test(inline, stringbased):
user_id = Column(Integer, ForeignKey('users.id'))
if inline:
if stringbased:
- user = relation("User", primaryjoin="User.id==Address.user_id", backref="addresses")
+ user = relationship("User", primaryjoin="User.id==Address.user_id", backref="addresses")
else:
- user = relation(User, primaryjoin=User.id==user_id, backref="addresses")
+ user = relationship(User, primaryjoin=User.id==user_id, backref="addresses")
if not inline:
compile_mappers()
if stringbased:
- Address.user = relation("User", primaryjoin="User.id==Address.user_id", backref="addresses")
+ Address.user = relationship("User", primaryjoin="User.id==Address.user_id", backref="addresses")
else:
- Address.user = relation(User, primaryjoin=User.id==Address.user_id, backref="addresses")
+ Address.user = relationship(User, primaryjoin=User.id==Address.user_id, backref="addresses")
@classmethod
def insert_data(cls):
@@ -1629,7 +1629,7 @@ def _produce_test(inline, stringbased):
def test_aliased_join(self):
# this query will screw up if the aliasing
# enabled in query.join() gets applied to the right half of the join condition inside the any().
- # the join condition inside of any() comes from the "primaryjoin" of the relation,
+ # the join condition inside of any() comes from the "primaryjoin" of the relationship,
# and should not be annotated with _orm_adapt. PropertyLoader.Comparator will annotate
# the left side with _orm_adapt, though.
sess = create_session()
@@ -1692,7 +1692,7 @@ class DeclarativeReflectionTest(testing.TestBase):
__autoload__ = True
if testing.against('oracle', 'firebird'):
id = Column('id', Integer, primary_key=True, test_needs_autoincrement=True)
- addresses = relation("Address", backref="user")
+ addresses = relationship("Address", backref="user")
class Address(Base, ComparableEntity):
__tablename__ = 'addresses'
@@ -1728,7 +1728,7 @@ class DeclarativeReflectionTest(testing.TestBase):
if testing.against('oracle', 'firebird'):
id = Column('id', Integer, primary_key=True, test_needs_autoincrement=True)
nom = Column('name', String(50), key='nom')
- addresses = relation("Address", backref="user")
+ addresses = relationship("Address", backref="user")
class Address(Base, ComparableEntity):
__tablename__ = 'addresses'
@@ -1772,7 +1772,7 @@ class DeclarativeReflectionTest(testing.TestBase):
__autoload__ = True
if testing.against('oracle', 'firebird'):
id = Column('id', Integer, primary_key=True, test_needs_autoincrement=True)
- handles = relation("IMHandle", backref="user")
+ handles = relationship("IMHandle", backref="user")
u1 = User(name='u1', handles=[
IMHandle(network='blabber', handle='foo'),
diff --git a/test/ext/test_orderinglist.py b/test/ext/test_orderinglist.py
index 4adc77960..479e44d63 100644
--- a/test/ext/test_orderinglist.py
+++ b/test/ext/test_orderinglist.py
@@ -46,7 +46,7 @@ class OrderingListTest(TestBase):
metadata.clear()
def _setup(self, test_collection_class):
- """Build a relation situation using the given test_collection_class
+ """Build a relationship situation using the given test_collection_class
factory"""
global metadata, slides_table, bullets_table, Slide, Bullet
@@ -77,7 +77,7 @@ class OrderingListTest(TestBase):
return '<Bullet "%s" pos %s>' % (self.text, self.position)
mapper(Slide, slides_table, properties={
- 'bullets': relation(Bullet, lazy=False,
+ 'bullets': relationship(Bullet, lazy=False,
collection_class=test_collection_class,
backref='slide',
order_by=[bullets_table.c.position])
diff --git a/test/ext/test_serializer.py b/test/ext/test_serializer.py
index 7e5a73efe..f06677eb9 100644
--- a/test/ext/test_serializer.py
+++ b/test/ext/test_serializer.py
@@ -6,7 +6,7 @@ from sqlalchemy.test import testing
from sqlalchemy import MetaData, Integer, String, ForeignKey, select, desc, func, util
from sqlalchemy.test.schema import Table
from sqlalchemy.test.schema import Column
-from sqlalchemy.orm import relation, sessionmaker, scoped_session, class_mapper, mapper, eagerload, compile_mappers, aliased
+from sqlalchemy.orm import relationship, sessionmaker, scoped_session, class_mapper, mapper, eagerload, compile_mappers, aliased
from sqlalchemy.test.testing import eq_
from test.orm._base import ComparableEntity, MappedTest
@@ -42,7 +42,7 @@ class SerializeTest(MappedTest):
Session = scoped_session(sessionmaker())
mapper(User, users, properties={
- 'addresses':relation(Address, backref='user', order_by=addresses.c.id)
+ 'addresses':relationship(Address, backref='user', order_by=addresses.c.id)
})
mapper(Address, addresses)
diff --git a/test/orm/inheritance/test_abc_inheritance.py b/test/orm/inheritance/test_abc_inheritance.py
index fac08b2f7..edbd476ec 100644
--- a/test/orm/inheritance/test_abc_inheritance.py
+++ b/test/orm/inheritance/test_abc_inheritance.py
@@ -76,9 +76,9 @@ def produce_test(parent, child, direction):
btoc = tc.c.id==tb.c.id
if direction == ONETOMANY:
- relationjoin = parent_table.c.id==child_table.c.parent_id
+ relationshipjoin = parent_table.c.id==child_table.c.parent_id
elif direction == MANYTOONE:
- relationjoin = parent_table.c.child_id==child_table.c.id
+ relationshipjoin = parent_table.c.child_id==child_table.c.id
if parent is child:
remote_side = [child_table.c.id]
@@ -111,7 +111,7 @@ def produce_test(parent, child, direction):
parent_class = parent_mapper.class_
child_class = child_mapper.class_
- parent_mapper.add_property("collection", relation(child_mapper, primaryjoin=relationjoin, foreign_keys=foreign_keys, remote_side=remote_side, uselist=True))
+ parent_mapper.add_property("collection", relationship(child_mapper, primaryjoin=relationshipjoin, foreign_keys=foreign_keys, remote_side=remote_side, uselist=True))
sess = create_session()
diff --git a/test/orm/inheritance/test_basic.py b/test/orm/inheritance/test_basic.py
index ce773a7bc..9477fddab 100644
--- a/test/orm/inheritance/test_basic.py
+++ b/test/orm/inheritance/test_basic.py
@@ -47,7 +47,7 @@ class O2MTest(_base.MappedTest):
return "Blub id %d, data %s" % (self.id, self.data)
mapper(Blub, blub, inherits=Bar, properties={
- 'parent_foo':relation(Foo)
+ 'parent_foo':relationship(Foo)
})
sess = create_session()
@@ -141,7 +141,7 @@ class PolymorphicSynonymTest(_base.MappedTest):
class CascadeTest(_base.MappedTest):
- """that cascades on polymorphic relations continue
+ """that cascades on polymorphic relationships continue
cascading along the path of the instance's mapper, not
the base mapper."""
@@ -179,11 +179,11 @@ class CascadeTest(_base.MappedTest):
pass
mapper(T1, t1, properties={
- 't2s':relation(T2, cascade="all")
+ 't2s':relationship(T2, cascade="all")
})
mapper(T2, t2, polymorphic_on=t2.c.type, polymorphic_identity='t2')
mapper(T3, t3, inherits=T2, polymorphic_identity='t3', properties={
- 't4s':relation(T4, cascade="all")
+ 't4s':relationship(T4, cascade="all")
})
mapper(T4, t4)
@@ -239,10 +239,10 @@ class M2OUseGetTest(_base.MappedTest):
# previously, this was needed for the comparison to occur:
# the 'primaryjoin' looks just like "Sub"'s "get" clause (based on the Base id),
# and foreign_keys since that join condition doesn't actually have any fks in it
- #'sub':relation(Sub, primaryjoin=base.c.id==related.c.sub_id, foreign_keys=related.c.sub_id)
+ #'sub':relationship(Sub, primaryjoin=base.c.id==related.c.sub_id, foreign_keys=related.c.sub_id)
# now we can use this:
- 'sub':relation(Sub)
+ 'sub':relationship(Sub)
})
assert class_mapper(Related).get_property('sub').strategy.use_get
@@ -383,8 +383,8 @@ class EagerLazyTest(_base.MappedTest):
foos = mapper(Foo, foo)
bars = mapper(Bar, bar, inherits=foos)
- bars.add_property('lazy', relation(foos, bar_foo, lazy=True))
- bars.add_property('eager', relation(foos, bar_foo, lazy=False))
+ bars.add_property('lazy', relationship(foos, bar_foo, lazy=True))
+ bars.add_property('eager', relationship(foos, bar_foo, lazy=False))
foo.insert().execute(data='foo1')
bar.insert().execute(id=1, data='bar1')
@@ -430,7 +430,7 @@ class EagerTargetingTest(_base.MappedTest):
mapper(A, a_table, polymorphic_on=a_table.c.type, polymorphic_identity='A',
properties={
- 'children': relation(A, order_by=a_table.c.name)
+ 'children': relationship(A, order_by=a_table.c.name)
})
mapper(B, b_table, inherits=A, polymorphic_identity='B', properties={
@@ -492,7 +492,7 @@ class FlushTest(_base.MappedTest):
class Admin(User):pass
role_mapper = mapper(Role, roles)
user_mapper = mapper(User, users, properties = {
- 'roles' : relation(Role, secondary=user_roles, lazy=False)
+ 'roles' : relationship(Role, secondary=user_roles, lazy=False)
}
)
admin_mapper = mapper(Admin, admins, inherits=user_mapper)
@@ -528,7 +528,7 @@ class FlushTest(_base.MappedTest):
role_mapper = mapper(Role, roles)
user_mapper = mapper(User, users, properties = {
- 'roles' : relation(Role, secondary=user_roles, lazy=False)
+ 'roles' : relationship(Role, secondary=user_roles, lazy=False)
}
)
@@ -584,7 +584,7 @@ class VersioningTest(_base.MappedTest):
polymorphic_on=base.c.discriminator,
version_id_col=base.c.version_id,
polymorphic_identity=1, properties={
- 'stuff':relation(Stuff)
+ 'stuff':relationship(Stuff)
})
mapper(Sub, subtable, inherits=Base, polymorphic_identity=2)
@@ -1194,7 +1194,7 @@ class PKDiscriminatorTest(_base.MappedTest):
pass
mapper(Parent, parents, properties={
- 'children': relation(Child, backref='parent'),
+ 'children': relationship(Child, backref='parent'),
})
mapper(Child, children, polymorphic_on=children.c.type,
polymorphic_identity=1)
@@ -1249,7 +1249,7 @@ class DeleteOrphanTest(_base.MappedTest):
mapper(Base, single, polymorphic_on=single.c.type, polymorphic_identity='base')
mapper(SubClass, inherits=Base, polymorphic_identity='sub')
mapper(Parent, parent, properties={
- 'related':relation(Base, cascade="all, delete-orphan")
+ 'related':relationship(Base, cascade="all, delete-orphan")
})
sess = create_session()
diff --git a/test/orm/inheritance/test_concrete.py b/test/orm/inheritance/test_concrete.py
index 3a78be9d7..be921b00b 100644
--- a/test/orm/inheritance/test_concrete.py
+++ b/test/orm/inheritance/test_concrete.py
@@ -286,14 +286,14 @@ class ConcreteTest(_base.MappedTest):
set(["Engineer Jerry knows how to program", "Hacker Kurt 'Badass' knows how to hack"])
)
- def test_relation(self):
+ def test_relationship(self):
pjoin = polymorphic_union({
'manager':managers_table,
'engineer':engineers_table
}, 'type', 'pjoin')
mapper(Company, companies, properties={
- 'employees':relation(Employee)
+ 'employees':relationship(Employee)
})
employee_mapper = mapper(Employee, pjoin, polymorphic_on=pjoin.c.type)
manager_mapper = mapper(Manager, managers_table, inherits=employee_mapper, concrete=True, polymorphic_identity='manager')
@@ -350,7 +350,7 @@ class PropertyInheritanceTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_noninherited_warning(self):
mapper(A, a_table, properties={
- 'some_c':relation(C)
+ 'some_c':relationship(C)
})
mapper(B, b_table,inherits=A, concrete=True)
mapper(C, c_table)
@@ -378,14 +378,14 @@ class PropertyInheritanceTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_inheriting(self):
mapper(A, a_table, properties={
- 'some_c':relation(C, back_populates='many_a')
+ 'some_c':relationship(C, back_populates='many_a')
})
mapper(B, b_table,inherits=A, concrete=True, properties={
- 'some_c':relation(C, back_populates='many_b')
+ 'some_c':relationship(C, back_populates='many_b')
})
mapper(C, c_table, properties={
- 'many_a':relation(A, back_populates='some_c'),
- 'many_b':relation(B, back_populates='some_c'),
+ 'many_a':relationship(A, back_populates='some_c'),
+ 'many_b':relationship(B, back_populates='some_c'),
})
sess = sessionmaker()()
@@ -426,15 +426,15 @@ class PropertyInheritanceTest(_base.MappedTest):
mapper(A, a_table, with_polymorphic=('*', ajoin),
polymorphic_on=ajoin.c.type, polymorphic_identity='a',
properties={
- 'some_c':relation(C, back_populates='many_a')
+ 'some_c':relationship(C, back_populates='many_a')
})
mapper(B, b_table,inherits=A, concrete=True,
polymorphic_identity='b',
properties={
- 'some_c':relation(C, back_populates='many_a')
+ 'some_c':relationship(C, back_populates='many_a')
})
mapper(C, c_table, properties={
- 'many_a':relation(A, back_populates='some_c', order_by=ajoin.c.id),
+ 'many_a':relationship(A, back_populates='some_c', order_by=ajoin.c.id),
})
sess = sessionmaker()()
@@ -498,12 +498,12 @@ class ManyToManyTest(_base.MappedTest):
pass
@testing.resolve_artifact_names
- def test_selective_relations(self):
+ def test_selective_relationships(self):
mapper(Base, base, properties={
- 'related':relation(Related, secondary=base_mtom, backref='bases', order_by=related.c.id)
+ 'related':relationship(Related, secondary=base_mtom, backref='bases', order_by=related.c.id)
})
mapper(Sub, sub, inherits=Base, concrete=True, properties={
- 'related':relation(Related, secondary=sub_mtom, backref='subs', order_by=related.c.id)
+ 'related':relationship(Related, secondary=sub_mtom, backref='subs', order_by=related.c.id)
})
mapper(Related, related)
diff --git a/test/orm/inheritance/test_magazine.py b/test/orm/inheritance/test_magazine.py
index f94781c27..27f6e3753 100644
--- a/test/orm/inheritance/test_magazine.py
+++ b/test/orm/inheritance/test_magazine.py
@@ -126,21 +126,21 @@ def generate_round_trip_test(use_unions=False, use_joins=False):
publication_mapper = mapper(Publication, publication_table)
issue_mapper = mapper(Issue, issue_table, properties = {
- 'publication': relation(Publication, backref=backref('issues', cascade="all, delete-orphan")),
+ 'publication': relationship(Publication, backref=backref('issues', cascade="all, delete-orphan")),
})
location_name_mapper = mapper(LocationName, location_name_table)
location_mapper = mapper(Location, location_table, properties = {
- 'issue': relation(Issue, backref=backref('locations', lazy=False, cascade="all, delete-orphan")),
- '_name': relation(LocationName),
+ 'issue': relationship(Issue, backref=backref('locations', lazy=False, cascade="all, delete-orphan")),
+ '_name': relationship(LocationName),
})
page_size_mapper = mapper(PageSize, page_size_table)
magazine_mapper = mapper(Magazine, magazine_table, properties = {
- 'location': relation(Location, backref=backref('magazine', uselist=False)),
- 'size': relation(PageSize),
+ 'location': relationship(Location, backref=backref('magazine', uselist=False)),
+ 'size': relationship(PageSize),
})
if use_unions:
@@ -164,16 +164,16 @@ def generate_round_trip_test(use_unions=False, use_joins=False):
'c': page_table.join(magazine_page_table).join(classified_page_table),
}, None, 'page_join')
magazine_page_mapper = mapper(MagazinePage, magazine_page_table, with_polymorphic=('*', magazine_join), inherits=page_mapper, polymorphic_identity='m', properties={
- 'magazine': relation(Magazine, backref=backref('pages', order_by=magazine_join.c.page_no))
+ 'magazine': relationship(Magazine, backref=backref('pages', order_by=magazine_join.c.page_no))
})
elif use_joins:
magazine_join = page_table.join(magazine_page_table).outerjoin(classified_page_table)
magazine_page_mapper = mapper(MagazinePage, magazine_page_table, with_polymorphic=('*', magazine_join), inherits=page_mapper, polymorphic_identity='m', properties={
- 'magazine': relation(Magazine, backref=backref('pages', order_by=page_table.c.page_no))
+ 'magazine': relationship(Magazine, backref=backref('pages', order_by=page_table.c.page_no))
})
else:
magazine_page_mapper = mapper(MagazinePage, magazine_page_table, inherits=page_mapper, polymorphic_identity='m', properties={
- 'magazine': relation(Magazine, backref=backref('pages', order_by=page_table.c.page_no))
+ 'magazine': relationship(Magazine, backref=backref('pages', order_by=page_table.c.page_no))
})
classified_page_mapper = mapper(ClassifiedPage,
diff --git a/test/orm/inheritance/test_manytomany.py b/test/orm/inheritance/test_manytomany.py
index 7b6ad04eb..1bdbe795b 100644
--- a/test/orm/inheritance/test_manytomany.py
+++ b/test/orm/inheritance/test_manytomany.py
@@ -55,7 +55,7 @@ class InheritTest(_base.MappedTest):
mapper(User, users, inherits=Principal)
mapper(Group, groups, inherits=Principal, properties={
- 'users': relation(User, secondary=user_group_map,
+ 'users': relationship(User, secondary=user_group_map,
lazy=True, backref="groups")
})
@@ -116,7 +116,7 @@ class InheritTest2(_base.MappedTest):
pass
mapper(Bar, bar, inherits=Foo, properties={
- 'foos': relation(Foo, secondary=foo_bar, lazy=False)
+ 'foos': relationship(Foo, secondary=foo_bar, lazy=False)
})
sess = create_session()
@@ -185,7 +185,7 @@ class InheritTest3(_base.MappedTest):
return "Bar id %d, data %s" % (self.id, self.data)
mapper(Bar, bar, inherits=Foo, properties={
- 'foos' :relation(Foo, secondary=bar_foo, lazy=True)
+ 'foos' :relationship(Foo, secondary=bar_foo, lazy=True)
})
sess = create_session()
@@ -220,8 +220,8 @@ class InheritTest3(_base.MappedTest):
return "Blub id %d, data %s, bars %s, foos %s" % (self.id, self.data, repr([b for b in self.bars]), repr([f for f in self.foos]))
mapper(Blub, blub, inherits=Bar, properties={
- 'bars':relation(Bar, secondary=blub_bar, lazy=False),
- 'foos':relation(Foo, secondary=blub_foo, lazy=False),
+ 'bars':relationship(Bar, secondary=blub_bar, lazy=False),
+ 'foos':relationship(Foo, secondary=blub_foo, lazy=False),
})
sess = create_session()
diff --git a/test/orm/inheritance/test_poly_linked_list.py b/test/orm/inheritance/test_poly_linked_list.py
index e434218b9..bc954c47d 100644
--- a/test/orm/inheritance/test_poly_linked_list.py
+++ b/test/orm/inheritance/test_poly_linked_list.py
@@ -73,10 +73,10 @@ class PolymorphicCircularTest(_base.MappedTest):
polymorphic_on=table1.c.type,
polymorphic_identity='table1',
properties={
- 'nxt': relation(Table1,
+ 'nxt': relationship(Table1,
backref=backref('prev', foreignkey=join.c.id, uselist=False),
uselist=False, primaryjoin=join.c.id==join.c.related_id),
- 'data':relation(mapper(Data, data))
+ 'data':relationship(mapper(Data, data))
},
order_by=table1.c.id)
table1_mapper.compile()
@@ -87,8 +87,8 @@ class PolymorphicCircularTest(_base.MappedTest):
# currently, the "eager" relationships degrade to lazy relationships
# due to the polymorphic load.
- # the "nxt" relation used to have a "lazy=False" on it, but the EagerLoader raises the "self-referential"
- # exception now. since eager loading would never work for that relation anyway, its better that the user
+ # the "nxt" relationship used to have a "lazy=False" on it, but the EagerLoader raises the "self-referential"
+ # exception now. since eager loading would never work for that relationship anyway, its better that the user
# gets an exception instead of it silently not eager loading.
# NOTE: using "nxt" instead of "next" to avoid 2to3 turning it into __next__() for some reason.
table1_mapper = mapper(Table1, table1,
@@ -96,10 +96,10 @@ class PolymorphicCircularTest(_base.MappedTest):
polymorphic_on=table1.c.type,
polymorphic_identity='table1',
properties={
- 'nxt': relation(Table1,
+ 'nxt': relationship(Table1,
backref=backref('prev', remote_side=table1.c.id, uselist=False),
uselist=False, primaryjoin=table1.c.id==table1.c.related_id),
- 'data':relation(mapper(Data, data), lazy=False, order_by=data.c.id)
+ 'data':relationship(mapper(Data, data), lazy=False, order_by=data.c.id)
},
order_by=table1.c.id
)
diff --git a/test/orm/inheritance/test_polymorph.py b/test/orm/inheritance/test_polymorph.py
index cd3b2d89e..eed2395d7 100644
--- a/test/orm/inheritance/test_polymorph.py
+++ b/test/orm/inheritance/test_polymorph.py
@@ -1,4 +1,4 @@
-"""tests basic polymorphic mapper loading/saving, minimal relations"""
+"""tests basic polymorphic mapper loading/saving, minimal relationships"""
from sqlalchemy.test.testing import eq_, assert_raises, assert_raises_message
from sqlalchemy import *
@@ -70,7 +70,7 @@ class InsertOrderTest(PolymorphTest):
mapper(Engineer, engineers, inherits=person_mapper, polymorphic_identity='engineer')
mapper(Manager, managers, inherits=person_mapper, polymorphic_identity='manager')
mapper(Company, companies, properties={
- 'employees': relation(Person,
+ 'employees': relationship(Person,
backref='company',
order_by=person_join.c.person_id)
})
@@ -87,17 +87,17 @@ class InsertOrderTest(PolymorphTest):
session.expunge_all()
eq_(session.query(Company).get(c.company_id), c)
-class RelationToSubclassTest(PolymorphTest):
+class RelationshipToSubclassTest(PolymorphTest):
def test_basic(self):
- """test a relation to an inheriting mapper where the relation is to a subclass
+ """test a relationship to an inheriting mapper where the relationship is to a subclass
but the join condition is expressed by the parent table.
also test that backrefs work in this case.
this test touches upon a lot of the join/foreign key determination code in properties.py
and creates the need for properties.py to search for conditions individually within
- the mapper's local table as well as the mapper's 'mapped' table, so that relations
- requiring lots of specificity (like self-referential joins) as well as relations requiring
+ the mapper's local table as well as the mapper's 'mapped' table, so that relationships
+ requiring lots of specificity (like self-referential joins) as well as relationships requiring
more generalization (like the example here) both come up with proper results."""
mapper(Person, people)
@@ -106,7 +106,7 @@ class RelationToSubclassTest(PolymorphTest):
mapper(Manager, managers, inherits=Person)
mapper(Company, companies, properties={
- 'managers': relation(Manager, backref="company")
+ 'managers': relationship(Manager, backref="company")
})
sess = create_session()
@@ -123,11 +123,11 @@ class RelationToSubclassTest(PolymorphTest):
class RoundTripTest(PolymorphTest):
pass
-def _generate_round_trip_test(include_base, lazy_relation, redefine_colprop, with_polymorphic):
+def _generate_round_trip_test(include_base, lazy_relationship, redefine_colprop, with_polymorphic):
"""generates a round trip test.
include_base - whether or not to include the base 'person' type in the union.
- lazy_relation - whether or not the Company relation to People is lazy or eager.
+ lazy_relationship - whether or not the Company relationship to People is lazy or eager.
redefine_colprop - if we redefine the 'name' column to be 'people_name' on the base Person class
use_literal_join - primary join condition is explicitly specified
"""
@@ -173,7 +173,7 @@ def _generate_round_trip_test(include_base, lazy_relation, redefine_colprop, wit
mapper(Boss, boss, inherits=Manager, polymorphic_identity='boss')
mapper(Company, companies, properties={
- 'employees': relation(Person, lazy=lazy_relation,
+ 'employees': relationship(Person, lazy=lazy_relationship,
cascade="all, delete-orphan",
backref="company", order_by=people.c.person_id
)
@@ -217,7 +217,7 @@ def _generate_round_trip_test(include_base, lazy_relation, redefine_colprop, wit
cc = session.query(Company).get(c.company_id)
eq_(cc.employees, employees)
- if not lazy_relation:
+ if not lazy_relationship:
if with_polymorphic != 'none':
self.assert_sql_count(testing.db, go, 1)
else:
@@ -287,18 +287,18 @@ def _generate_round_trip_test(include_base, lazy_relation, redefine_colprop, wit
test_roundtrip = function_named(
test_roundtrip, "test_%s%s%s_%s" % (
- (lazy_relation and "lazy" or "eager"),
+ (lazy_relationship and "lazy" or "eager"),
(include_base and "_inclbase" or ""),
(redefine_colprop and "_redefcol" or ""),
with_polymorphic))
setattr(RoundTripTest, test_roundtrip.__name__, test_roundtrip)
-for lazy_relation in [True, False]:
+for lazy_relationship in [True, False]:
for redefine_colprop in [True, False]:
for with_polymorphic in ['unions', 'joins', 'auto', 'none']:
if with_polymorphic == 'unions':
for include_base in [True, False]:
- _generate_round_trip_test(include_base, lazy_relation, redefine_colprop, with_polymorphic)
+ _generate_round_trip_test(include_base, lazy_relationship, redefine_colprop, with_polymorphic)
else:
- _generate_round_trip_test(False, lazy_relation, redefine_colprop, with_polymorphic)
+ _generate_round_trip_test(False, lazy_relationship, redefine_colprop, with_polymorphic)
diff --git a/test/orm/inheritance/test_polymorph2.py b/test/orm/inheritance/test_polymorph2.py
index 6181cbdb6..94939b33c 100644
--- a/test/orm/inheritance/test_polymorph2.py
+++ b/test/orm/inheritance/test_polymorph2.py
@@ -20,7 +20,7 @@ class AttrSettable(object):
return self.__class__.__name__ + "(%s)" % (hex(id(self)))
-class RelationTest1(_base.MappedTest):
+class RelationshipTest1(_base.MappedTest):
"""test self-referential relationships on polymorphic mappers"""
@classmethod
def define_tables(cls, metadata):
@@ -40,7 +40,7 @@ class RelationTest1(_base.MappedTest):
def teardown(self):
people.update(values={people.c.manager_id:None}).execute()
- super(RelationTest1, self).teardown()
+ super(RelationshipTest1, self).teardown()
def test_parent_refs_descendant(self):
class Person(AttrSettable):
@@ -51,7 +51,7 @@ class RelationTest1(_base.MappedTest):
# note that up until recently (0.4.4), we had to specify "foreign_keys" here
# for this primary join.
mapper(Person, people, properties={
- 'manager':relation(Manager, primaryjoin=(people.c.manager_id ==
+ 'manager':relationship(Manager, primaryjoin=(people.c.manager_id ==
managers.c.person_id),
uselist=False, post_update=True)
})
@@ -81,7 +81,7 @@ class RelationTest1(_base.MappedTest):
mapper(Person, people)
mapper(Manager, managers, inherits=Person, inherit_condition=people.c.person_id==managers.c.person_id, properties={
- 'employee':relation(Person, primaryjoin=(people.c.manager_id ==
+ 'employee':relationship(Person, primaryjoin=(people.c.manager_id ==
managers.c.person_id),
foreign_keys=[people.c.manager_id],
uselist=False, post_update=True)
@@ -100,7 +100,7 @@ class RelationTest1(_base.MappedTest):
print p, m, m.employee
assert m.employee is p
-class RelationTest2(_base.MappedTest):
+class RelationshipTest2(_base.MappedTest):
"""test self-referential relationships on polymorphic mappers"""
@classmethod
def define_tables(cls, metadata):
@@ -121,17 +121,17 @@ class RelationTest2(_base.MappedTest):
Column('data', String(30))
)
- def testrelationonsubclass_j1_nodata(self):
+ def testrelationshiponsubclass_j1_nodata(self):
self.do_test("join1", False)
- def testrelationonsubclass_j2_nodata(self):
+ def testrelationshiponsubclass_j2_nodata(self):
self.do_test("join2", False)
- def testrelationonsubclass_j1_data(self):
+ def testrelationshiponsubclass_j1_data(self):
self.do_test("join1", True)
- def testrelationonsubclass_j2_data(self):
+ def testrelationshiponsubclass_j2_data(self):
self.do_test("join2", True)
- def testrelationonsubclass_j3_nodata(self):
+ def testrelationshiponsubclass_j3_nodata(self):
self.do_test("join3", False)
- def testrelationonsubclass_j3_data(self):
+ def testrelationshiponsubclass_j3_data(self):
self.do_test("join3", True)
def do_test(self, jointype="join1", usedata=False):
@@ -167,14 +167,14 @@ class RelationTest2(_base.MappedTest):
if usedata:
mapper(Manager, managers, inherits=Person, inherit_condition=people.c.person_id==managers.c.person_id, polymorphic_identity='manager',
properties={
- 'colleague':relation(Person, primaryjoin=managers.c.manager_id==people.c.person_id, lazy=True, uselist=False),
- 'data':relation(Data, uselist=False)
+ 'colleague':relationship(Person, primaryjoin=managers.c.manager_id==people.c.person_id, lazy=True, uselist=False),
+ 'data':relationship(Data, uselist=False)
}
)
else:
mapper(Manager, managers, inherits=Person, inherit_condition=people.c.person_id==managers.c.person_id, polymorphic_identity='manager',
properties={
- 'colleague':relation(Person, primaryjoin=managers.c.manager_id==people.c.person_id, lazy=True, uselist=False)
+ 'colleague':relationship(Person, primaryjoin=managers.c.manager_id==people.c.person_id, lazy=True, uselist=False)
}
)
@@ -196,7 +196,7 @@ class RelationTest2(_base.MappedTest):
if usedata:
assert m.data.data == 'ms data'
-class RelationTest3(_base.MappedTest):
+class RelationshipTest3(_base.MappedTest):
"""test self-referential relationships on polymorphic mappers"""
@classmethod
def define_tables(cls, metadata):
@@ -250,14 +250,14 @@ def _generate_test(jointype="join1", usedata=False):
if usedata:
mapper(Person, people, with_polymorphic=('*', poly_union), polymorphic_identity='person', polymorphic_on=people.c.type,
properties={
- 'colleagues':relation(Person, primaryjoin=people.c.colleague_id==people.c.person_id, remote_side=people.c.colleague_id, uselist=True),
- 'data':relation(Data, uselist=False)
+ 'colleagues':relationship(Person, primaryjoin=people.c.colleague_id==people.c.person_id, remote_side=people.c.colleague_id, uselist=True),
+ 'data':relationship(Data, uselist=False)
}
)
else:
mapper(Person, people, with_polymorphic=('*', poly_union), polymorphic_identity='person', polymorphic_on=people.c.type,
properties={
- 'colleagues':relation(Person, primaryjoin=people.c.colleague_id==people.c.person_id,
+ 'colleagues':relationship(Person, primaryjoin=people.c.colleague_id==people.c.person_id,
remote_side=people.c.colleague_id, uselist=True)
}
)
@@ -293,17 +293,17 @@ def _generate_test(jointype="join1", usedata=False):
assert m.data.data == 'ms data'
do_test = function_named(
- do_test, 'test_relation_on_base_class_%s_%s' % (
+ do_test, 'test_relationship_on_base_class_%s_%s' % (
jointype, data and "nodata" or "data"))
return do_test
for jointype in ["join1", "join2", "join3", "join4"]:
for data in (True, False):
func = _generate_test(jointype, data)
- setattr(RelationTest3, func.__name__, func)
+ setattr(RelationshipTest3, func.__name__, func)
del func
-class RelationTest4(_base.MappedTest):
+class RelationshipTest4(_base.MappedTest):
@classmethod
def define_tables(cls, metadata):
global people, engineers, managers, cars
@@ -359,7 +359,7 @@ class RelationTest4(_base.MappedTest):
person_mapper = mapper(Person, people, with_polymorphic=('*', employee_join), polymorphic_on=employee_join.c.type, polymorphic_identity='person')
engineer_mapper = mapper(Engineer, engineers, inherits=person_mapper, polymorphic_identity='engineer')
manager_mapper = mapper(Manager, managers, inherits=person_mapper, polymorphic_identity='manager')
- car_mapper = mapper(Car, cars, properties= {'employee':relation(person_mapper)})
+ car_mapper = mapper(Car, cars, properties= {'employee':relationship(person_mapper)})
session = create_session()
@@ -416,7 +416,7 @@ class RelationTest4(_base.MappedTest):
c = s.join("employee").filter(Person.name=="E4")[0]
assert c.car_id==car1.car_id
-class RelationTest5(_base.MappedTest):
+class RelationshipTest5(_base.MappedTest):
@classmethod
def define_tables(cls, metadata):
global people, engineers, managers, cars
@@ -438,7 +438,7 @@ class RelationTest5(_base.MappedTest):
Column('owner', Integer, ForeignKey('people.person_id')))
def test_eager_empty(self):
- """test parent object with child relation to an inheriting mapper, using eager loads,
+ """test parent object with child relationship to an inheriting mapper, using eager loads,
works when there are no child objects present"""
class Person(object):
def __init__(self, **kwargs):
@@ -462,7 +462,7 @@ class RelationTest5(_base.MappedTest):
person_mapper = mapper(Person, people, polymorphic_on=people.c.type, polymorphic_identity='person')
engineer_mapper = mapper(Engineer, engineers, inherits=person_mapper, polymorphic_identity='engineer')
manager_mapper = mapper(Manager, managers, inherits=person_mapper, polymorphic_identity='manager')
- car_mapper = mapper(Car, cars, properties= {'manager':relation(manager_mapper, lazy=False)})
+ car_mapper = mapper(Car, cars, properties= {'manager':relationship(manager_mapper, lazy=False)})
sess = create_session()
car1 = Car()
@@ -477,7 +477,7 @@ class RelationTest5(_base.MappedTest):
assert carlist[0].manager is None
assert carlist[1].manager.person_id == car2.manager.person_id
-class RelationTest6(_base.MappedTest):
+class RelationshipTest6(_base.MappedTest):
"""test self-referential relationships on a single joined-table inheritance mapper"""
@classmethod
def define_tables(cls, metadata):
@@ -505,7 +505,7 @@ class RelationTest6(_base.MappedTest):
# to parent.mapped_table
mapper(Manager, managers, inherits=Person, inherit_condition=people.c.person_id==managers.c.person_id,
properties={
- 'colleague':relation(Manager, primaryjoin=managers.c.colleague_id==managers.c.person_id, lazy=True, uselist=False)
+ 'colleague':relationship(Manager, primaryjoin=managers.c.colleague_id==managers.c.person_id, lazy=True, uselist=False)
}
)
@@ -521,7 +521,7 @@ class RelationTest6(_base.MappedTest):
m2 = sess.query(Manager).get(m2.person_id)
assert m.colleague is m2
-class RelationTest7(_base.MappedTest):
+class RelationshipTest7(_base.MappedTest):
@classmethod
def define_tables(cls, metadata):
global people, engineers, managers, cars, offroad_cars
@@ -599,7 +599,7 @@ class RelationTest7(_base.MappedTest):
with_polymorphic=('*', employee_join), polymorphic_on=employee_join.c.type,
polymorphic_identity='person',
properties={
- 'car':relation(car_mapper)
+ 'car':relationship(car_mapper)
})
engineer_mapper = mapper(Engineer, engineers, inherits=person_mapper, polymorphic_identity='engineer')
manager_mapper = mapper(Manager, managers, inherits=person_mapper, polymorphic_identity='manager')
@@ -622,7 +622,7 @@ class RelationTest7(_base.MappedTest):
for p in r:
assert p.car_id == p.car.car_id
-class RelationTest8(_base.MappedTest):
+class RelationshipTest8(_base.MappedTest):
@classmethod
def define_tables(cls, metadata):
global taggable, users
@@ -644,7 +644,7 @@ class RelationTest8(_base.MappedTest):
pass
mapper( Taggable, taggable, polymorphic_on=taggable.c.type, polymorphic_identity='taggable', properties = {
- 'owner' : relation (User,
+ 'owner' : relationship (User,
primaryjoin=taggable.c.owner_id ==taggable.c.id,
remote_side=taggable.c.id
),
@@ -745,10 +745,10 @@ class GenerativeTest(TestBase, AssertsExecutionResults):
status_mapper = mapper(Status, status)
person_mapper = mapper(Person, people,
with_polymorphic=('*', employee_join), polymorphic_on=employee_join.c.type,
- polymorphic_identity='person', properties={'status':relation(status_mapper)})
+ polymorphic_identity='person', properties={'status':relationship(status_mapper)})
engineer_mapper = mapper(Engineer, engineers, inherits=person_mapper, polymorphic_identity='engineer')
manager_mapper = mapper(Manager, managers, inherits=person_mapper, polymorphic_identity='manager')
- car_mapper = mapper(Car, cars, properties= {'employee':relation(person_mapper), 'status':relation(status_mapper)})
+ car_mapper = mapper(Car, cars, properties= {'employee':relationship(person_mapper), 'status':relationship(status_mapper)})
session = create_session()
@@ -914,7 +914,7 @@ class ManyToManyPolyTest(_base.MappedTest):
with_polymorphic=('*', item_join),
polymorphic_on=base_item_table.c.child_name,
polymorphic_identity='BaseItem',
- properties=dict(collections=relation(Collection, secondary=base_item_collection_table, backref="items")))
+ properties=dict(collections=relationship(Collection, secondary=base_item_collection_table, backref="items")))
mapper(
Item, item_table,
@@ -1049,7 +1049,7 @@ class InheritingEagerTest(_base.MappedTest):
self.label = label
mapper(Person, people, polymorphic_on=people.c._type,polymorphic_identity='person', properties={
- 'tags': relation(Tag, secondary=peopleTags,backref='people', lazy=False)
+ 'tags': relationship(Tag, secondary=peopleTags,backref='people', lazy=False)
})
mapper(Employee, employees, inherits=Person,polymorphic_identity='employee')
mapper(Tag, tags)
@@ -1107,7 +1107,7 @@ class MissingPolymorphicOnTest(_base.MappedTest):
mapper(B, tableb)
mapper(A, tablea, with_polymorphic=('*', poly_select), polymorphic_on=poly_select.c.discriminator, properties={
- 'b':relation(B, uselist=False)
+ 'b':relationship(B, uselist=False)
})
mapper(C, tablec, inherits=A,polymorphic_identity='c')
mapper(D, tabled, inherits=C, polymorphic_identity='d')
diff --git a/test/orm/inheritance/test_productspec.py b/test/orm/inheritance/test_productspec.py
index deb7564a8..450900355 100644
--- a/test/orm/inheritance/test_productspec.py
+++ b/test/orm/inheritance/test_productspec.py
@@ -92,12 +92,12 @@ class InheritTest(_base.MappedTest):
specification_mapper = mapper(SpecLine, specification_table,
properties=dict(
- master=relation(Assembly,
+ master=relationship(Assembly,
foreign_keys=[specification_table.c.master_id],
primaryjoin=specification_table.c.master_id==products_table.c.product_id,
lazy=True, backref=backref('specification'),
uselist=False),
- slave=relation(Product,
+ slave=relationship(Product,
foreign_keys=[specification_table.c.slave_id],
primaryjoin=specification_table.c.slave_id==products_table.c.product_id,
lazy=True, uselist=False),
@@ -136,7 +136,7 @@ class InheritTest(_base.MappedTest):
specification_mapper = mapper(SpecLine, specification_table,
properties=dict(
- slave=relation(Product,
+ slave=relationship(Product,
foreign_keys=[specification_table.c.slave_id],
primaryjoin=specification_table.c.slave_id==products_table.c.product_id,
lazy=True, uselist=False),
@@ -168,12 +168,12 @@ class InheritTest(_base.MappedTest):
specification_mapper = mapper(SpecLine, specification_table,
properties=dict(
- master=relation(Assembly, lazy=False, uselist=False,
+ master=relationship(Assembly, lazy=False, uselist=False,
foreign_keys=[specification_table.c.master_id],
primaryjoin=specification_table.c.master_id==products_table.c.product_id,
backref=backref('specification', cascade="all, delete-orphan"),
),
- slave=relation(Product, lazy=False, uselist=False,
+ slave=relationship(Product, lazy=False, uselist=False,
foreign_keys=[specification_table.c.slave_id],
primaryjoin=specification_table.c.slave_id==products_table.c.product_id,
),
@@ -187,7 +187,7 @@ class InheritTest(_base.MappedTest):
properties=dict(
name=documents_table.c.name,
data=deferred(documents_table.c.data),
- product=relation(Product, lazy=True, backref=backref('documents', cascade="all, delete-orphan")),
+ product=relationship(Product, lazy=True, backref=backref('documents', cascade="all, delete-orphan")),
),
)
raster_document_mapper = mapper(RasterDocument, inherits=document_mapper,
@@ -227,7 +227,7 @@ class InheritTest(_base.MappedTest):
properties=dict(
name=documents_table.c.name,
data=deferred(documents_table.c.data),
- product=relation(Product, lazy=True, backref=backref('documents', cascade="all, delete-orphan")),
+ product=relationship(Product, lazy=True, backref=backref('documents', cascade="all, delete-orphan")),
),
)
raster_document_mapper = mapper(RasterDocument, inherits=document_mapper,
@@ -260,12 +260,12 @@ class InheritTest(_base.MappedTest):
specification_mapper = mapper(SpecLine, specification_table,
properties=dict(
- master=relation(Assembly, lazy=False, uselist=False,
+ master=relationship(Assembly, lazy=False, uselist=False,
foreign_keys=[specification_table.c.master_id],
primaryjoin=specification_table.c.master_id==products_table.c.product_id,
backref=backref('specification'),
),
- slave=relation(Product, lazy=False, uselist=False,
+ slave=relationship(Product, lazy=False, uselist=False,
foreign_keys=[specification_table.c.slave_id],
primaryjoin=specification_table.c.slave_id==products_table.c.product_id,
),
@@ -276,7 +276,7 @@ class InheritTest(_base.MappedTest):
product_mapper = mapper(Product, products_table,
polymorphic_on=products_table.c.product_type,
polymorphic_identity='product', properties={
- 'documents' : relation(Document, lazy=True,
+ 'documents' : relationship(Document, lazy=True,
backref='product', cascade='all, delete-orphan'),
})
diff --git a/test/orm/inheritance/test_query.py b/test/orm/inheritance/test_query.py
index 256eaefa6..83297e165 100644
--- a/test/orm/inheritance/test_query.py
+++ b/test/orm/inheritance/test_query.py
@@ -80,7 +80,7 @@ def _produce_test(select_type):
clear_mappers()
mapper(Company, companies, properties={
- 'employees':relation(Person, order_by=people.c.person_id)
+ 'employees':relationship(Person, order_by=people.c.person_id)
})
mapper(Machine, machines)
@@ -120,10 +120,10 @@ def _produce_test(select_type):
with_polymorphic=person_with_polymorphic,
polymorphic_on=people.c.type, polymorphic_identity='person', order_by=people.c.person_id,
properties={
- 'paperwork':relation(Paperwork, order_by=paperwork.c.paperwork_id)
+ 'paperwork':relationship(Paperwork, order_by=paperwork.c.paperwork_id)
})
mapper(Engineer, engineers, inherits=Person, polymorphic_identity='engineer', properties={
- 'machines':relation(Machine, order_by=machines.c.machine_id)
+ 'machines':relationship(Machine, order_by=machines.c.machine_id)
})
mapper(Manager, managers, with_polymorphic=manager_with_polymorphic,
inherits=Person, polymorphic_identity='manager')
@@ -429,42 +429,42 @@ def _produce_test(select_type):
# compare to entities without related collections to prevent additional lazy SQL from firing on
# loaded entities
- emps_without_relations = [
+ emps_without_relationships = [
Engineer(name="dilbert", engineer_name="dilbert", primary_language="java", status="regular engineer"),
Engineer(name="wally", engineer_name="wally", primary_language="c++", status="regular engineer"),
Boss(name="pointy haired boss", golf_swing="fore", manager_name="pointy", status="da boss"),
Manager(name="dogbert", manager_name="dogbert", status="regular manager"),
Engineer(name="vlad", engineer_name="vlad", primary_language="cobol", status="elbonian engineer")
]
- eq_(sess.query(Person).with_polymorphic('*').all(), emps_without_relations)
+ eq_(sess.query(Person).with_polymorphic('*').all(), emps_without_relationships)
def go():
- eq_(sess.query(Person).with_polymorphic(Engineer).filter(Engineer.primary_language=='java').all(), emps_without_relations[0:1])
+ eq_(sess.query(Person).with_polymorphic(Engineer).filter(Engineer.primary_language=='java').all(), emps_without_relationships[0:1])
self.assert_sql_count(testing.db, go, 1)
sess.expunge_all()
def go():
- eq_(sess.query(Person).with_polymorphic('*').all(), emps_without_relations)
+ eq_(sess.query(Person).with_polymorphic('*').all(), emps_without_relationships)
self.assert_sql_count(testing.db, go, 1)
sess.expunge_all()
def go():
- eq_(sess.query(Person).with_polymorphic(Engineer).all(), emps_without_relations)
+ eq_(sess.query(Person).with_polymorphic(Engineer).all(), emps_without_relationships)
self.assert_sql_count(testing.db, go, 3)
sess.expunge_all()
def go():
- eq_(sess.query(Person).with_polymorphic(Engineer, people.outerjoin(engineers)).all(), emps_without_relations)
+ eq_(sess.query(Person).with_polymorphic(Engineer, people.outerjoin(engineers)).all(), emps_without_relationships)
self.assert_sql_count(testing.db, go, 3)
sess.expunge_all()
def go():
# limit the polymorphic join down to just "Person", overriding select_table
- eq_(sess.query(Person).with_polymorphic(Person).all(), emps_without_relations)
+ eq_(sess.query(Person).with_polymorphic(Person).all(), emps_without_relationships)
self.assert_sql_count(testing.db, go, 6)
- def test_relation_to_polymorphic(self):
+ def test_relationship_to_polymorphic(self):
assert_result = [
Company(name="MegaCorp, Inc.", employees=[
Engineer(name="dilbert", engineer_name="dilbert", primary_language="java", status="regular engineer", machines=[Machine(name="IBM ThinkPad"), Machine(name="IPhone")]),
@@ -504,7 +504,7 @@ def _produce_test(select_type):
self.assert_sql_count(testing.db, go, 1)
- def test_query_subclass_join_to_base_relation(self):
+ def test_query_subclass_join_to_base_relationship(self):
sess = create_session()
# non-polymorphic
eq_(sess.query(Engineer).join(Person.paperwork).all(), [e1, e2, e3])
@@ -823,7 +823,7 @@ class SelfReferentialTestJoinedToBase(_base.MappedTest):
mapper(Engineer, engineers, inherits=Person,
inherit_condition=engineers.c.person_id==people.c.person_id,
polymorphic_identity='engineer', properties={
- 'reports_to':relation(Person, primaryjoin=people.c.person_id==engineers.c.reports_to_id)
+ 'reports_to':relationship(Person, primaryjoin=people.c.person_id==engineers.c.reports_to_id)
})
def test_has(self):
@@ -888,7 +888,7 @@ class SelfReferentialJ2JTest(_base.MappedTest):
mapper(Engineer, engineers, inherits=Person,
polymorphic_identity='engineer', properties={
- 'reports_to':relation(Manager, primaryjoin=managers.c.person_id==engineers.c.reports_to_id, backref='engineers')
+ 'reports_to':relationship(Manager, primaryjoin=managers.c.person_id==engineers.c.reports_to_id, backref='engineers')
})
def test_has(self):
@@ -946,7 +946,7 @@ class SelfReferentialJ2JTest(_base.MappedTest):
]
)
- def test_relation_compare(self):
+ def test_relationship_compare(self):
m1 = Manager(name='dogbert')
m2 = Manager(name='foo')
e1 = Engineer(name='dilbert', primary_language='java', reports_to=m1)
@@ -1008,7 +1008,7 @@ class M2MFilterTest(_base.MappedTest):
pass
mapper(Organization, organizations, properties={
- 'engineers':relation(Engineer, secondary=engineers_to_org, backref='organizations')
+ 'engineers':relationship(Engineer, secondary=engineers_to_org, backref='organizations')
})
mapper(Person, people, polymorphic_on=people.c.type, polymorphic_identity='person')
@@ -1073,7 +1073,7 @@ class SelfReferentialM2MTest(_base.MappedTest, AssertsCompiledSQL):
id = Column(Integer, ForeignKey('parent.id'), primary_key=True)
__mapper_args__ = dict(polymorphic_identity = 'child2')
- Child1.left_child2 = relation(Child2, secondary = secondary_table,
+ Child1.left_child2 = relationship(Child2, secondary = secondary_table,
primaryjoin = Parent.id == secondary_table.c.right_id,
secondaryjoin = Parent.id == secondary_table.c.left_id,
uselist = False, backref="right_children"
@@ -1189,7 +1189,7 @@ class EagerToSubclassTest(_base.MappedTest):
@testing.resolve_artifact_names
def setup_mappers(cls):
mapper(Parent, parent, properties={
- 'children':relation(Sub)
+ 'children':relationship(Sub)
})
mapper(Base, base, polymorphic_on=base.c.type, polymorphic_identity='b')
mapper(Sub, sub, inherits=Base, polymorphic_identity='s')
@@ -1282,7 +1282,7 @@ class SubClassEagerToSubclassTest(_base.MappedTest):
def setup_mappers(cls):
mapper(Parent, parent, polymorphic_on=parent.c.type, polymorphic_identity='b')
mapper(Subparent, subparent, inherits=Parent, polymorphic_identity='s', properties={
- 'children':relation(Sub)
+ 'children':relationship(Sub)
})
mapper(Base, base, polymorphic_on=base.c.type, polymorphic_identity='b')
mapper(Sub, sub, inherits=Base, polymorphic_identity='s')
diff --git a/test/orm/inheritance/test_single.py b/test/orm/inheritance/test_single.py
index fc30955db..f54044d64 100644
--- a/test/orm/inheritance/test_single.py
+++ b/test/orm/inheritance/test_single.py
@@ -152,7 +152,7 @@ class SingleInheritanceTest(MappedTest):
class Report(ComparableEntity): pass
mapper(Report, reports, properties={
- 'employee': relation(Employee, backref='reports')})
+ 'employee': relationship(Employee, backref='reports')})
sess = create_session()
m1 = Manager(name='Tom', manager_data='data1')
@@ -169,7 +169,7 @@ class SingleInheritanceTest(MappedTest):
class Report(ComparableEntity): pass
mapper(Report, reports, properties={
- 'employee': relation(Employee, backref='reports')})
+ 'employee': relationship(Employee, backref='reports')})
sess = create_session()
m1 = Manager(name='Tom', manager_data='data1')
@@ -183,7 +183,7 @@ class SingleInheritanceTest(MappedTest):
assert len(rq.join(Report.employee.of_type(Engineer)).all()) == 0
-class RelationToSingleTest(MappedTest):
+class RelationshipToSingleTest(MappedTest):
@classmethod
def define_tables(cls, metadata):
Table('employees', metadata,
@@ -217,7 +217,7 @@ class RelationToSingleTest(MappedTest):
@testing.resolve_artifact_names
def test_of_type(self):
mapper(Company, companies, properties={
- 'employees':relation(Employee, backref='company')
+ 'employees':relationship(Employee, backref='company')
})
mapper(Employee, employees, polymorphic_on=employees.c.type)
mapper(Manager, inherits=Employee, polymorphic_identity='manager')
@@ -251,12 +251,12 @@ class RelationToSingleTest(MappedTest):
@testing.resolve_artifact_names
- def test_relation_to_subclass(self):
+ def test_relationship_to_subclass(self):
mapper(Company, companies, properties={
- 'engineers':relation(Engineer)
+ 'engineers':relationship(Engineer)
})
mapper(Employee, employees, polymorphic_on=employees.c.type, properties={
- 'company':relation(Company)
+ 'company':relationship(Company)
})
mapper(Manager, inherits=Employee, polymorphic_identity='manager')
mapper(Engineer, inherits=Employee, polymorphic_identity='engineer')
diff --git a/test/orm/sharding/test_shard.py b/test/orm/sharding/test_shard.py
index 06a38848b..2418dd8d4 100644
--- a/test/orm/sharding/test_shard.py
+++ b/test/orm/sharding/test_shard.py
@@ -124,7 +124,7 @@ class ShardTest(TestBase):
self.temperature = temperature
mapper(WeatherLocation, weather_locations, properties={
- 'reports':relation(Report, backref='location'),
+ 'reports':relationship(Report, backref='location'),
'city': deferred(weather_locations.c.city),
})
diff --git a/test/orm/test_association.py b/test/orm/test_association.py
index d537430cc..64915942c 100644
--- a/test/orm/test_association.py
+++ b/test/orm/test_association.py
@@ -2,7 +2,7 @@
from sqlalchemy.test import testing
from sqlalchemy import Integer, String, ForeignKey
from sqlalchemy.test.schema import Table, Column
-from sqlalchemy.orm import mapper, relation, create_session
+from sqlalchemy.orm import mapper, relationship, create_session
from test.orm import _base
from sqlalchemy.test.testing import eq_
@@ -55,12 +55,12 @@ class AssociationTest(_base.MappedTest):
mapper(Keyword, keywords)
mapper(KeywordAssociation, item_keywords, properties={
- 'keyword':relation(Keyword, lazy=False)},
+ 'keyword':relationship(Keyword, lazy=False)},
primary_key=[item_keywords.c.item_id, item_keywords.c.keyword_id],
order_by=[item_keywords.c.data])
mapper(Item, items, properties={
- 'keywords' : relation(KeywordAssociation,
+ 'keywords' : relationship(KeywordAssociation,
cascade="all, delete-orphan")
})
diff --git a/test/orm/test_assorted_eager.py b/test/orm/test_assorted_eager.py
index da0883c62..7fa3b6b8a 100644
--- a/test/orm/test_assorted_eager.py
+++ b/test/orm/test_assorted_eager.py
@@ -9,7 +9,7 @@ import sqlalchemy as sa
from sqlalchemy.test import testing
from sqlalchemy import Integer, String, ForeignKey
from sqlalchemy.test.schema import Table, Column
-from sqlalchemy.orm import mapper, relation, backref, create_session
+from sqlalchemy.orm import mapper, relationship, backref, create_session
from sqlalchemy.test.testing import eq_
from test.orm import _base
@@ -71,13 +71,13 @@ class EagerTest(_base.MappedTest):
mapper(Category, categories)
mapper(Option, options, properties=dict(
- owner=relation(Owner),
- test=relation(Thing)))
+ owner=relationship(Owner),
+ test=relationship(Thing)))
mapper(Thing, tests, properties=dict(
- owner=relation(Owner, backref='tests'),
- category=relation(Category),
- owner_option=relation(Option,
+ owner=relationship(Owner, backref='tests'),
+ category=relationship(Category),
+ owner_option=relationship(Option,
primaryjoin=sa.and_(tests.c.id == options.c.test_id,
tests.c.owner_id == options.c.owner_id),
foreign_keys=[options.c.test_id, options.c.owner_id],
@@ -237,10 +237,10 @@ class EagerTest2(_base.MappedTest):
mapper(Left, left)
mapper(Right, right)
mapper(Middle, middle, properties=dict(
- left=relation(Left,
+ left=relationship(Left,
lazy=False,
backref=backref('middle',lazy=False)),
- right=relation(Right,
+ right=relationship(Right,
lazy=False,
backref=backref('middle', lazy=False)))),
@@ -298,10 +298,10 @@ class EagerTest3(_base.MappedTest):
def test_nesting_with_functions(self):
mapper(Data, datas)
mapper(Foo, foo, properties={
- 'data': relation(Data,backref=backref('foo',uselist=False))})
+ 'data': relationship(Data,backref=backref('foo',uselist=False))})
mapper(Stat, stats, properties={
- 'data':relation(Data)})
+ 'data':relationship(Data)})
session = create_session()
@@ -374,7 +374,7 @@ class EagerTest4(_base.MappedTest):
def test_basic(self):
mapper(Employee, employees)
mapper(Department, departments, properties=dict(
- employees=relation(Employee,
+ employees=relationship(Employee,
lazy=False,
backref='department')))
@@ -451,7 +451,7 @@ class EagerTest5(_base.MappedTest):
commentMapper = mapper(Comment, comments)
baseMapper = mapper(Base, base, properties=dict(
- comments=relation(Comment, lazy=False,
+ comments=relationship(Comment, lazy=False,
cascade='all, delete-orphan')))
mapper(Derived, derived, inherits=baseMapper)
@@ -528,20 +528,20 @@ class EagerTest6(_base.MappedTest):
p_m = mapper(Part, parts)
mapper(InheritedPart, inherited_part, properties=dict(
- part=relation(Part, lazy=False)))
+ part=relationship(Part, lazy=False)))
d_m = mapper(Design, design, properties=dict(
- inheritedParts=relation(InheritedPart,
+ inheritedParts=relationship(InheritedPart,
cascade="all, delete-orphan",
backref="design")))
mapper(DesignType, design_types)
d_m.add_property(
- "type", relation(DesignType, lazy=False, backref="designs"))
+ "type", relationship(DesignType, lazy=False, backref="designs"))
p_m.add_property(
- "design", relation(
+ "design", relationship(
Design, lazy=False,
backref=backref("parts", cascade="all, delete-orphan")))
@@ -613,10 +613,10 @@ class EagerTest7(_base.MappedTest):
mapper(Address, addresses)
mapper(Company, companies, properties={
- 'addresses' : relation(Address, lazy=False)})
+ 'addresses' : relationship(Address, lazy=False)})
mapper(Invoice, invoices, properties={
- 'company': relation(Company, lazy=False)})
+ 'company': relationship(Company, lazy=False)})
a1 = Address(address='a1 address')
a2 = Address(address='a2 address')
@@ -646,19 +646,19 @@ class EagerTest7(_base.MappedTest):
mapper(Phone, phone_numbers)
mapper(Address, addresses, properties={
- 'phones': relation(Phone, lazy=False, backref='address',
+ 'phones': relationship(Phone, lazy=False, backref='address',
order_by=phone_numbers.c.phone_id)})
mapper(Company, companies, properties={
- 'addresses': relation(Address, lazy=False, backref='company',
+ 'addresses': relationship(Address, lazy=False, backref='company',
order_by=addresses.c.address_id)})
mapper(Item, items)
mapper(Invoice, invoices, properties={
- 'items': relation(Item, lazy=False, backref='invoice',
+ 'items': relationship(Item, lazy=False, backref='invoice',
order_by=items.c.item_id),
- 'company': relation(Company, lazy=False, backref='invoices')})
+ 'company': relationship(Company, lazy=False, backref='invoices')})
c1 = Company(company_name='company 1', addresses=[
Address(address='a1 address',
@@ -776,7 +776,7 @@ class EagerTest8(_base.MappedTest):
jjj = sa.join(task, jj, task.c.id == jj.c.task_id)
mapper(Joined, jjj, properties=dict(
- type=relation(Task_Type, lazy=False)))
+ type=relationship(Task_Type, lazy=False)))
session = create_session()
@@ -829,11 +829,11 @@ class EagerTest9(_base.MappedTest):
mapper(Transaction, transactions)
mapper(Entry, entries, properties=dict(
- account=relation(Account,
+ account=relationship(Account,
uselist=False,
backref=backref('entries', lazy=True,
order_by=entries.c.entry_id)),
- transaction=relation(Transaction,
+ transaction=relationship(Transaction,
uselist=False,
backref=backref('entries', lazy=False,
order_by=entries.c.entry_id))))
diff --git a/test/orm/test_backref_mutations.py b/test/orm/test_backref_mutations.py
index f0dfa254f..13b44e1bb 100644
--- a/test/orm/test_backref_mutations.py
+++ b/test/orm/test_backref_mutations.py
@@ -13,7 +13,7 @@ from sqlalchemy.test.testing import assert_raises, assert_raises_message
from sqlalchemy import Integer, String, ForeignKey, Sequence, exc as sa_exc
from sqlalchemy.test.schema import Table
from sqlalchemy.test.schema import Column
-from sqlalchemy.orm import mapper, relation, create_session, class_mapper, backref, sessionmaker
+from sqlalchemy.orm import mapper, relationship, create_session, class_mapper, backref, sessionmaker
from sqlalchemy.orm import attributes, exc as orm_exc
from sqlalchemy.test import testing
from sqlalchemy.test.testing import eq_
@@ -27,7 +27,7 @@ class O2MCollectionTest(_fixtures.FixtureTest):
def setup_mappers(cls):
mapper(Address, addresses)
mapper(User, users, properties = dict(
- addresses = relation(Address, backref="user"),
+ addresses = relationship(Address, backref="user"),
))
@testing.resolve_artifact_names
@@ -231,7 +231,7 @@ class O2OScalarBackrefMoveTest(_fixtures.FixtureTest):
def setup_mappers(cls):
mapper(Address, addresses)
mapper(User, users, properties = {
- 'address':relation(Address, backref=backref("user"), uselist=False)
+ 'address':relationship(Address, backref=backref("user"), uselist=False)
})
@testing.resolve_artifact_names
@@ -385,7 +385,7 @@ class O2OScalarMoveTest(_fixtures.FixtureTest):
def setup_mappers(cls):
mapper(Address, addresses)
mapper(User, users, properties = {
- 'address':relation(Address, uselist=False)
+ 'address':relationship(Address, uselist=False)
})
@testing.resolve_artifact_names
@@ -419,7 +419,7 @@ class O2OScalarOrphanTest(_fixtures.FixtureTest):
def setup_mappers(cls):
mapper(Address, addresses)
mapper(User, users, properties = {
- 'address':relation(Address, uselist=False,
+ 'address':relationship(Address, uselist=False,
backref=backref('user', single_parent=True, cascade="all, delete-orphan"))
})
@@ -448,7 +448,7 @@ class M2MScalarMoveTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def setup_mappers(cls):
mapper(Item, items, properties={
- 'keyword':relation(Keyword, secondary=item_keywords, uselist=False, backref=backref("item", uselist=False))
+ 'keyword':relationship(Keyword, secondary=item_keywords, uselist=False, backref=backref("item", uselist=False))
})
mapper(Keyword, keywords)
diff --git a/test/orm/test_cascade.py b/test/orm/test_cascade.py
index 6593d69f6..2725d7b0e 100644
--- a/test/orm/test_cascade.py
+++ b/test/orm/test_cascade.py
@@ -2,7 +2,7 @@
from sqlalchemy.test.testing import assert_raises, assert_raises_message
from sqlalchemy import Integer, String, ForeignKey, Sequence, exc as sa_exc
from sqlalchemy.test.schema import Table, Column
-from sqlalchemy.orm import mapper, relation, create_session, sessionmaker, class_mapper, backref
+from sqlalchemy.orm import mapper, relationship, create_session, sessionmaker, class_mapper, backref
from sqlalchemy.orm import attributes, exc as orm_exc
from sqlalchemy.test import testing
from sqlalchemy.test.testing import eq_
@@ -17,12 +17,12 @@ class O2MCascadeTest(_fixtures.FixtureTest):
def setup_mappers(cls):
mapper(Address, addresses)
mapper(User, users, properties = dict(
- addresses = relation(Address, cascade="all, delete-orphan", backref="user"),
- orders = relation(
+ addresses = relationship(Address, cascade="all, delete-orphan", backref="user"),
+ orders = relationship(
mapper(Order, orders), cascade="all, delete-orphan", order_by=orders.c.id)
))
mapper(Dingaling,dingalings, properties={
- 'address':relation(Address)
+ 'address':relationship(Address)
})
@testing.resolve_artifact_names
@@ -211,7 +211,7 @@ class O2OCascadeTest(_fixtures.FixtureTest):
def setup_mappers(cls):
mapper(Address, addresses)
mapper(User, users, properties = {
- 'address':relation(Address, backref=backref("user", single_parent=True), uselist=False)
+ 'address':relationship(Address, backref=backref("user", single_parent=True), uselist=False)
})
@testing.resolve_artifact_names
@@ -235,7 +235,7 @@ class O2MBackrefTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def setup_mappers(cls):
mapper(User, users, properties = dict(
- orders = relation(
+ orders = relationship(
mapper(Order, orders), cascade="all, delete-orphan", backref="user")
))
@@ -262,7 +262,7 @@ class NoSaveCascadeTest(_fixtures.FixtureTest):
def test_unidirectional_cascade_o2m(self):
mapper(Order, orders)
mapper(User, users, properties = dict(
- orders = relation(
+ orders = relationship(
Order, backref=backref("user", cascade=None))
))
@@ -285,7 +285,7 @@ class NoSaveCascadeTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_unidirectional_cascade_m2o(self):
mapper(Order, orders, properties={
- 'user':relation(User, backref=backref("orders", cascade=None))
+ 'user':relationship(User, backref=backref("orders", cascade=None))
})
mapper(User, users)
@@ -310,7 +310,7 @@ class NoSaveCascadeTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_unidirectional_cascade_m2m(self):
mapper(Item, items, properties={
- 'keywords':relation(Keyword, secondary=item_keywords, cascade="none", backref="items")
+ 'keywords':relationship(Keyword, secondary=item_keywords, cascade="none", backref="items")
})
mapper(Keyword, keywords)
@@ -340,7 +340,7 @@ class O2MCascadeNoOrphanTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def setup_mappers(cls):
mapper(User, users, properties = dict(
- orders = relation(
+ orders = relationship(
mapper(Order, orders), cascade="all")
))
@@ -400,11 +400,11 @@ class M2OCascadeTest(_base.MappedTest):
def setup_mappers(cls):
mapper(Extra, extra)
mapper(Pref, prefs, properties=dict(
- extra = relation(Extra, cascade="all, delete")
+ extra = relationship(Extra, cascade="all, delete")
))
mapper(User, users, properties = dict(
- pref = relation(Pref, lazy=False, cascade="all, delete-orphan", single_parent=True ),
- foo = relation(Foo) # straight m2o
+ pref = relationship(Pref, lazy=False, cascade="all, delete-orphan", single_parent=True ),
+ foo = relationship(Foo) # straight m2o
))
mapper(Foo, foo)
@@ -550,8 +550,8 @@ class M2OCascadeDeleteTest(_base.MappedTest):
@classmethod
@testing.resolve_artifact_names
def setup_mappers(cls):
- mapper(T1, t1, properties={'t2': relation(T2, cascade="all")})
- mapper(T2, t2, properties={'t3': relation(T3, cascade="all")})
+ mapper(T1, t1, properties={'t2': relationship(T2, cascade="all")})
+ mapper(T2, t2, properties={'t3': relationship(T3, cascade="all")})
mapper(T3, t3)
@testing.resolve_artifact_names
@@ -672,9 +672,9 @@ class M2OCascadeDeleteOrphanTest(_base.MappedTest):
@testing.resolve_artifact_names
def setup_mappers(cls):
mapper(T1, t1, properties=dict(
- t2=relation(T2, cascade="all, delete-orphan", single_parent=True)))
+ t2=relationship(T2, cascade="all, delete-orphan", single_parent=True)))
mapper(T2, t2, properties=dict(
- t3=relation(T3, cascade="all, delete-orphan", single_parent=True, backref=backref('t2', uselist=False))))
+ t3=relationship(T3, cascade="all, delete-orphan", single_parent=True, backref=backref('t2', uselist=False))))
mapper(T3, t3)
@testing.resolve_artifact_names
@@ -801,7 +801,7 @@ class M2MCascadeTest(_base.MappedTest):
mapper(A, a, properties={
# if no backref here, delete-orphan failed until [ticket:427] was
# fixed
- 'bs': relation(B, secondary=atob, cascade="all, delete-orphan", single_parent=True)
+ 'bs': relationship(B, secondary=atob, cascade="all, delete-orphan", single_parent=True)
})
mapper(B, b)
@@ -822,7 +822,7 @@ class M2MCascadeTest(_base.MappedTest):
mapper(A, a, properties={
# if no backref here, delete-orphan failed until [ticket:427] was
# fixed
- 'bs': relation(B, secondary=atob,
+ 'bs': relationship(B, secondary=atob,
cascade="all, delete-orphan", single_parent=True,lazy="dynamic")
})
mapper(B, b)
@@ -844,9 +844,9 @@ class M2MCascadeTest(_base.MappedTest):
mapper(A, a, properties={
# if no backref here, delete-orphan failed until [ticket:427] was
# fixed
- 'bs':relation(B, secondary=atob, cascade="all, delete-orphan", single_parent=True)
+ 'bs':relationship(B, secondary=atob, cascade="all, delete-orphan", single_parent=True)
})
- mapper(B, b, properties={'cs':relation(C, cascade="all, delete-orphan")})
+ mapper(B, b, properties={'cs':relationship(C, cascade="all, delete-orphan")})
mapper(C, c)
sess = create_session()
@@ -865,7 +865,7 @@ class M2MCascadeTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_cascade_delete(self):
mapper(A, a, properties={
- 'bs':relation(B, secondary=atob, cascade="all, delete-orphan", single_parent=True)
+ 'bs':relationship(B, secondary=atob, cascade="all, delete-orphan", single_parent=True)
})
mapper(B, b)
@@ -883,7 +883,7 @@ class M2MCascadeTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_single_parent_raise(self):
mapper(A, a, properties={
- 'bs':relation(B, secondary=atob, cascade="all, delete-orphan", single_parent=True)
+ 'bs':relationship(B, secondary=atob, cascade="all, delete-orphan", single_parent=True)
})
mapper(B, b)
@@ -900,7 +900,7 @@ class M2MCascadeTest(_base.MappedTest):
"""test that setting m2m via a uselist=False backref bypasses the single_parent raise"""
mapper(A, a, properties={
- 'bs':relation(B,
+ 'bs':relationship(B,
secondary=atob,
cascade="all, delete-orphan", single_parent=True,
backref=backref('a', uselist=False))
@@ -948,7 +948,7 @@ class UnsavedOrphansTest(_base.MappedTest):
mapper(Address, addresses)
mapper(User, users, properties=dict(
- addresses=relation(Address, cascade="all,delete-orphan", backref="user")
+ addresses=relationship(Address, cascade="all,delete-orphan", backref="user")
))
s = create_session()
a = Address()
@@ -965,7 +965,7 @@ class UnsavedOrphansTest(_base.MappedTest):
mapper(Address, addresses)
mapper(User, users, properties=dict(
- addresses=relation(Address, cascade="all,delete-orphan", backref="user")
+ addresses=relationship(Address, cascade="all,delete-orphan", backref="user")
))
s = create_session()
@@ -989,7 +989,7 @@ class UnsavedOrphansTest(_base.MappedTest):
def test_nonorphans_ok(self):
mapper(Address, addresses)
mapper(User, users, properties=dict(
- addresses=relation(Address, cascade="all,delete", backref="user")
+ addresses=relationship(Address, cascade="all,delete", backref="user")
))
s = create_session()
u = User(name='u1', addresses=[Address(email_address='ad1')])
@@ -1034,10 +1034,10 @@ class UnsavedOrphansTest2(_base.MappedTest):
mapper(Attribute, attributes)
mapper(Item, items, properties=dict(
- attributes=relation(Attribute, cascade="all,delete-orphan", backref="item")
+ attributes=relationship(Attribute, cascade="all,delete-orphan", backref="item")
))
mapper(Order, orders, properties=dict(
- items=relation(Item, cascade="all,delete-orphan", backref="order")
+ items=relationship(Item, cascade="all,delete-orphan", backref="order")
))
s = create_session()
@@ -1079,7 +1079,7 @@ class UnsavedOrphansTest3(_base.MappedTest):
@testing.resolve_artifact_names
def test_double_parent_expunge_o2m(self):
- """test the delete-orphan uow event for multiple delete-orphan parent relations."""
+ """test the delete-orphan uow event for multiple delete-orphan parent relationships."""
class Customer(_fixtures.Base):
pass
@@ -1090,11 +1090,11 @@ class UnsavedOrphansTest3(_base.MappedTest):
mapper(Customer, customers)
mapper(Account, accounts, properties=dict(
- customers=relation(Customer,
+ customers=relationship(Customer,
cascade="all,delete-orphan",
backref="account")))
mapper(SalesRep, sales_reps, properties=dict(
- customers=relation(Customer,
+ customers=relationship(Customer,
cascade="all,delete-orphan",
backref="sales_rep")))
s = create_session()
@@ -1118,7 +1118,7 @@ class UnsavedOrphansTest3(_base.MappedTest):
@testing.resolve_artifact_names
def test_double_parent_expunge_o2o(self):
- """test the delete-orphan uow event for multiple delete-orphan parent relations."""
+ """test the delete-orphan uow event for multiple delete-orphan parent relationships."""
class Customer(_fixtures.Base):
pass
@@ -1129,11 +1129,11 @@ class UnsavedOrphansTest3(_base.MappedTest):
mapper(Customer, customers)
mapper(Account, accounts, properties=dict(
- customer=relation(Customer,
+ customer=relationship(Customer,
cascade="all,delete-orphan",
backref="account", uselist=False)))
mapper(SalesRep, sales_reps, properties=dict(
- customer=relation(Customer,
+ customer=relationship(Customer,
cascade="all,delete-orphan",
backref="sales_rep", uselist=False)))
s = create_session()
@@ -1158,7 +1158,7 @@ class UnsavedOrphansTest3(_base.MappedTest):
class DoubleParentOrphanTest(_base.MappedTest):
- """test orphan detection for an entity with two parent relations"""
+ """test orphan detection for an entity with two parent relationships"""
@classmethod
def define_tables(cls, metadata):
@@ -1193,8 +1193,8 @@ class DoubleParentOrphanTest(_base.MappedTest):
pass
mapper(Address, addresses)
- mapper(Home, homes, properties={'address':relation(Address, cascade="all,delete-orphan", single_parent=True)})
- mapper(Business, businesses, properties={'address':relation(Address, cascade="all,delete-orphan", single_parent=True)})
+ mapper(Home, homes, properties={'address':relationship(Address, cascade="all,delete-orphan", single_parent=True)})
+ mapper(Business, businesses, properties={'address':relationship(Address, cascade="all,delete-orphan", single_parent=True)})
session = create_session()
h1 = Home(description='home1', address=Address(street='address1'))
@@ -1219,8 +1219,8 @@ class DoubleParentOrphanTest(_base.MappedTest):
pass
mapper(Address, addresses)
- mapper(Home, homes, properties={'address':relation(Address, cascade="all,delete-orphan", single_parent=True)})
- mapper(Business, businesses, properties={'address':relation(Address, cascade="all,delete-orphan", single_parent=True)})
+ mapper(Home, homes, properties={'address':relationship(Address, cascade="all,delete-orphan", single_parent=True)})
+ mapper(Business, businesses, properties={'address':relationship(Address, cascade="all,delete-orphan", single_parent=True)})
session = create_session()
a1 = Address()
@@ -1250,7 +1250,7 @@ class CollectionAssignmentOrphanTest(_base.MappedTest):
pass
mapper(A, table_a, properties={
- 'bs':relation(B, cascade="all, delete-orphan")
+ 'bs':relationship(B, cascade="all, delete-orphan")
})
mapper(B, table_b)
@@ -1310,7 +1310,7 @@ class PartialFlushTest(_base.MappedTest):
pass
mapper(Base, base, properties={
- 'children':relation(Child, backref='parent')
+ 'children':relationship(Child, backref='parent')
})
mapper(Child, noninh_child)
@@ -1367,7 +1367,7 @@ class PartialFlushTest(_base.MappedTest):
mapper(Child, inh_child,
inherits=Base,
- properties={'parent': relation(
+ properties={'parent': relationship(
Parent,
backref='children',
primaryjoin=inh_child.c.parent_id == parent.c.id
diff --git a/test/orm/test_collection.py b/test/orm/test_collection.py
index 3d1b30bc9..7dcc5c56f 100644
--- a/test/orm/test_collection.py
+++ b/test/orm/test_collection.py
@@ -10,7 +10,7 @@ from sqlalchemy.test import testing
from sqlalchemy import Integer, String, ForeignKey
from sqlalchemy.test.schema import Table, Column
from sqlalchemy import util, exc as sa_exc
-from sqlalchemy.orm import create_session, mapper, relation, attributes
+from sqlalchemy.orm import create_session, mapper, relationship, attributes
from test.orm import _base
from sqlalchemy.test.testing import eq_, assert_raises
@@ -1438,7 +1438,7 @@ class DictHelpersTest(_base.MappedTest):
def _test_scalar_mapped(self, collection_class):
mapper(Child, children)
mapper(Parent, parents, properties={
- 'children': relation(Child, collection_class=collection_class,
+ 'children': relationship(Child, collection_class=collection_class,
cascade="all, delete-orphan")})
p = Parent()
@@ -1497,7 +1497,7 @@ class DictHelpersTest(_base.MappedTest):
def _test_composite_mapped(self, collection_class):
mapper(Child, children)
mapper(Parent, parents, properties={
- 'children': relation(Child, collection_class=collection_class,
+ 'children': relationship(Child, collection_class=collection_class,
cascade="all, delete-orphan")
})
@@ -1556,8 +1556,8 @@ class DictHelpersTest(_base.MappedTest):
class Bar(BaseObject):
__tablename__ = "bar"
id = Column(Integer(), primary_key=True, test_needs_autoincrement=True)
- foos = relation(Foo, collection_class=collections.column_mapped_collection(Foo.id))
- foos2 = relation(Foo, collection_class=collections.column_mapped_collection((Foo.id, Foo.bar_id)))
+ foos = relationship(Foo, collection_class=collections.column_mapped_collection(Foo.id))
+ foos2 = relationship(Foo, collection_class=collections.column_mapped_collection((Foo.id, Foo.bar_id)))
eq_(Bar.foos.property.collection_class().keyfunc(Foo(id=3)), 3)
eq_(Bar.foos2.property.collection_class().keyfunc(Foo(id=3, bar_id=12)), (3, 12))
@@ -1614,7 +1614,7 @@ class CustomCollectionsTest(_base.MappedTest):
pass
mapper(Foo, sometable, properties={
- 'bars':relation(Bar, collection_class=MyList)
+ 'bars':relationship(Bar, collection_class=MyList)
})
mapper(Bar, someothertable)
f = Foo()
@@ -1628,7 +1628,7 @@ class CustomCollectionsTest(_base.MappedTest):
class Bar(object):
pass
mapper(Foo, sometable, properties={
- 'bars':relation(Bar, collection_class=set)
+ 'bars':relationship(Bar, collection_class=set)
})
mapper(Bar, someothertable)
f = Foo()
@@ -1660,7 +1660,7 @@ class CustomCollectionsTest(_base.MappedTest):
del self[id(item)]
mapper(Foo, sometable, properties={
- 'bars':relation(Bar, collection_class=AppenderDict)
+ 'bars':relationship(Bar, collection_class=AppenderDict)
})
mapper(Bar, someothertable)
f = Foo()
@@ -1684,7 +1684,7 @@ class CustomCollectionsTest(_base.MappedTest):
def __init__(self, data): self.data = data
mapper(Foo, sometable, properties={
- 'bars':relation(Bar,
+ 'bars':relationship(Bar,
collection_class=collections.column_mapped_collection(
someothertable.c.data))
})
@@ -1757,7 +1757,7 @@ class CustomCollectionsTest(_base.MappedTest):
pass
mapper(Parent, sometable, properties={
- 'children':relation(Child, collection_class=listcls)
+ 'children':relationship(Child, collection_class=listcls)
})
mapper(Child, someothertable)
@@ -1892,7 +1892,7 @@ class CustomCollectionsTest(_base.MappedTest):
return iter(self.data)
mapper(Parent, sometable, properties={
- 'children':relation(Child, collection_class=MyCollection)
+ 'children':relationship(Child, collection_class=MyCollection)
})
mapper(Child, someothertable)
diff --git a/test/orm/test_compile.py b/test/orm/test_compile.py
index 7a5b63615..9d70ece16 100644
--- a/test/orm/test_compile.py
+++ b/test/orm/test_compile.py
@@ -52,17 +52,17 @@ class CompileTest(_base.ORMTest):
polymorphic_on=order_join.c.type,
polymorphic_identity='order',
properties={
- 'orderproducts': relation(OrderProduct, lazy=True, backref='order')}
+ 'orderproducts': relationship(OrderProduct, lazy=True, backref='order')}
)
mapper(Product, product,
properties={
- 'orderproducts': relation(OrderProduct, lazy=True, backref='product')}
+ 'orderproducts': relationship(OrderProduct, lazy=True, backref='product')}
)
mapper(Employee, employee,
properties={
- 'orders': relation(Order, lazy=True, backref='employee')})
+ 'orders': relationship(Order, lazy=True, backref='employee')})
mapper(OrderProduct, orderproduct)
@@ -105,12 +105,12 @@ class CompileTest(_base.ORMTest):
polymorphic_on=order_join.c.type,
polymorphic_identity='order',
properties={
- 'orderproducts': relation(OrderProduct, lazy=True, backref='product')}
+ 'orderproducts': relationship(OrderProduct, lazy=True, backref='product')}
)
mapper(Product, product,
properties={
- 'orderproducts': relation(OrderProduct, lazy=True, backref='product')}
+ 'orderproducts': relationship(OrderProduct, lazy=True, backref='product')}
)
mapper(OrderProduct, orderproduct)
@@ -149,8 +149,8 @@ class CompileTest(_base.ORMTest):
host_mapper = mapper(Host, host_table)
node_name_mapper = mapper(NodeName, node_name_table,
properties = {
- 'node' : relation(Node, backref=backref('names')),
- 'host' : relation(Host),
+ 'node' : relationship(Node, backref=backref('names')),
+ 'host' : relationship(Host),
}
)
sess = create_session()
@@ -168,10 +168,10 @@ class CompileTest(_base.ORMTest):
class B(object):pass
mapper(A, a, properties={
- 'b':relation(B, backref='a')
+ 'b':relationship(B, backref='a')
})
mapper(B, b, properties={
- 'a':relation(A, backref='b')
+ 'a':relationship(A, backref='b')
})
try:
diff --git a/test/orm/test_cycles.py b/test/orm/test_cycles.py
index 6fbfe7fe1..fa233f681 100644
--- a/test/orm/test_cycles.py
+++ b/test/orm/test_cycles.py
@@ -8,7 +8,7 @@ T1/T2.
from sqlalchemy.test import testing
from sqlalchemy import Integer, String, ForeignKey
from sqlalchemy.test.schema import Table, Column
-from sqlalchemy.orm import mapper, relation, backref, create_session
+from sqlalchemy.orm import mapper, relationship, backref, create_session
from sqlalchemy.test.testing import eq_
from sqlalchemy.test.assertsql import RegexSQL, ExactSQL, CompiledSQL, AllOf
from test.orm import _base
@@ -43,8 +43,8 @@ class SelfReferentialTest(_base.MappedTest):
@testing.resolve_artifact_names
def testsingle(self):
mapper(C1, t1, properties = {
- 'c1s':relation(C1, cascade="all"),
- 'parent':relation(C1,
+ 'c1s':relationship(C1, cascade="all"),
+ 'parent':relationship(C1,
primaryjoin=t1.c.parent_c1 == t1.c.c1,
remote_side=t1.c.c1,
lazy=True,
@@ -65,7 +65,7 @@ class SelfReferentialTest(_base.MappedTest):
test that the circular dependency sort can assemble a many-to-one
dependency processor when only the object on the "many" side is
actually in the list of modified objects. this requires that the
- circular sort add the other side of the relation into the
+ circular sort add the other side of the relationship into the
UOWTransaction so that the dependency operation can be tacked onto it.
This also affects inheritance relationships since they rely upon
@@ -73,7 +73,7 @@ class SelfReferentialTest(_base.MappedTest):
"""
mapper(C1, t1, properties={
- 'parent':relation(C1,
+ 'parent':relationship(C1,
primaryjoin=t1.c.parent_c1 == t1.c.c1,
remote_side=t1.c.c1)})
@@ -93,8 +93,8 @@ class SelfReferentialTest(_base.MappedTest):
@testing.resolve_artifact_names
def testcycle(self):
mapper(C1, t1, properties = {
- 'c1s' : relation(C1, cascade="all"),
- 'c2s' : relation(mapper(C2, t2), cascade="all, delete-orphan")})
+ 'c1s' : relationship(C1, cascade="all"),
+ 'c2s' : relationship(mapper(C2, t2), cascade="all, delete-orphan")})
a = C1('head c1')
a.c1s.append(C1('child1'))
@@ -113,7 +113,7 @@ class SelfReferentialTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_setnull_ondelete(self):
mapper(C1, t1, properties={
- 'children':relation(C1)
+ 'children':relationship(C1)
})
sess = create_session()
@@ -152,7 +152,7 @@ class SelfReferentialNoPKTest(_base.MappedTest):
@testing.resolve_artifact_names
def setup_mappers(cls):
mapper(TT, item, properties={
- 'children': relation(
+ 'children': relationship(
TT,
remote_side=[item.c.parent_uuid],
backref=backref('parent', remote_side=[item.c.uuid]))})
@@ -220,7 +220,7 @@ class InheritTestOne(_base.MappedTest):
mapper(Parent, parent)
mapper(Child1, child1, inherits=Parent)
mapper(Child2, child2, inherits=Parent, properties=dict(
- child1=relation(Child1,
+ child1=relationship(Child1,
primaryjoin=child2.c.child1_id == child1.c.id)))
@testing.resolve_artifact_names
@@ -287,12 +287,12 @@ class InheritTestTwo(_base.MappedTest):
@testing.resolve_artifact_names
def test_flush(self):
mapper(A, a, properties={
- 'cs':relation(C, primaryjoin=a.c.cid==c.c.id)})
+ 'cs':relationship(C, primaryjoin=a.c.cid==c.c.id)})
mapper(B, b, inherits=A, inherit_condition=b.c.id == a.c.id)
mapper(C, c, properties={
- 'arel':relation(A, primaryjoin=a.c.id == c.c.aid)})
+ 'arel':relationship(A, primaryjoin=a.c.id == c.c.aid)})
sess = create_session()
bobj = B()
@@ -335,12 +335,12 @@ class BiDirectionalManyToOneTest(_base.MappedTest):
@testing.resolve_artifact_names
def setup_mappers(cls):
mapper(T1, t1, properties={
- 't2':relation(T2, primaryjoin=t1.c.t2id == t2.c.id)})
+ 't2':relationship(T2, primaryjoin=t1.c.t2id == t2.c.id)})
mapper(T2, t2, properties={
- 't1':relation(T1, primaryjoin=t2.c.t1id == t1.c.id)})
+ 't1':relationship(T1, primaryjoin=t2.c.t1id == t1.c.id)})
mapper(T3, t3, properties={
- 't1':relation(T1),
- 't2':relation(T2)})
+ 't1':relationship(T1),
+ 't2':relationship(T2)})
@testing.resolve_artifact_names
def test_reflush(self):
@@ -392,7 +392,7 @@ class BiDirectionalManyToOneTest(_base.MappedTest):
class BiDirectionalOneToManyTest(_base.MappedTest):
- """tests two mappers with a one-to-many relation to each other."""
+ """tests two mappers with a one-to-many relationship to each other."""
run_define_tables = 'each'
@@ -418,11 +418,11 @@ class BiDirectionalOneToManyTest(_base.MappedTest):
@testing.resolve_artifact_names
def testcycle(self):
mapper(C2, t2, properties={
- 'c1s': relation(C1,
+ 'c1s': relationship(C1,
primaryjoin=t2.c.c1 == t1.c.c2,
uselist=True)})
mapper(C1, t1, properties={
- 'c2s': relation(C2,
+ 'c2s': relationship(C2,
primaryjoin=t1.c.c1 == t2.c.c2,
uselist=True)})
@@ -441,7 +441,7 @@ class BiDirectionalOneToManyTest(_base.MappedTest):
class BiDirectionalOneToManyTest2(_base.MappedTest):
- """Two mappers with a one-to-many relation to each other, with a second one-to-many on one of the mappers"""
+ """Two mappers with a one-to-many relationship to each other, with a second one-to-many on one of the mappers"""
run_define_tables = 'each'
@@ -479,14 +479,14 @@ class BiDirectionalOneToManyTest2(_base.MappedTest):
@testing.resolve_artifact_names
def setup_mappers(cls):
mapper(C2, t2, properties={
- 'c1s': relation(C1,
+ 'c1s': relationship(C1,
primaryjoin=t2.c.c1 == t1.c.c2,
uselist=True)})
mapper(C1, t1, properties={
- 'c2s': relation(C2,
+ 'c2s': relationship(C2,
primaryjoin=t1.c.c1 == t2.c.c2,
uselist=True),
- 'data': relation(mapper(C1Data, t1_data))})
+ 'data': relationship(mapper(C1Data, t1_data))})
@testing.resolve_artifact_names
def testcycle(self):
@@ -553,10 +553,10 @@ class OneToManyManyToOneTest(_base.MappedTest):
"""
mapper(Ball, ball)
mapper(Person, person, properties=dict(
- balls=relation(Ball,
+ balls=relationship(Ball,
primaryjoin=ball.c.person_id == person.c.id,
remote_side=ball.c.person_id),
- favorite=relation(Ball,
+ favorite=relationship(Ball,
primaryjoin=person.c.favorite_ball_id == ball.c.id,
remote_side=ball.c.id)))
@@ -572,12 +572,12 @@ class OneToManyManyToOneTest(_base.MappedTest):
"""A cycle between two rows, with a post_update on the many-to-one"""
mapper(Ball, ball)
mapper(Person, person, properties=dict(
- balls=relation(Ball,
+ balls=relationship(Ball,
primaryjoin=ball.c.person_id == person.c.id,
remote_side=ball.c.person_id,
post_update=False,
cascade="all, delete-orphan"),
- favorite=relation(Ball,
+ favorite=relationship(Ball,
primaryjoin=person.c.favorite_ball_id == ball.c.id,
remote_side=person.c.favorite_ball_id,
post_update=True)))
@@ -625,13 +625,13 @@ class OneToManyManyToOneTest(_base.MappedTest):
mapper(Ball, ball)
mapper(Person, person, properties=dict(
- balls=relation(Ball,
+ balls=relationship(Ball,
primaryjoin=ball.c.person_id == person.c.id,
remote_side=ball.c.person_id,
cascade="all, delete-orphan",
post_update=True,
backref='person'),
- favorite=relation(Ball,
+ favorite=relationship(Ball,
primaryjoin=person.c.favorite_ball_id == ball.c.id,
remote_side=person.c.favorite_ball_id)))
@@ -752,20 +752,20 @@ class SelfReferentialPostUpdateTest(_base.MappedTest):
"""
mapper(Node, node, properties={
- 'children': relation(
+ 'children': relationship(
Node,
primaryjoin=node.c.id==node.c.parent_id,
lazy=True,
cascade="all",
backref=backref("parent", remote_side=node.c.id)
),
- 'prev_sibling': relation(
+ 'prev_sibling': relationship(
Node,
primaryjoin=node.c.prev_sibling_id==node.c.id,
remote_side=node.c.id,
lazy=True,
uselist=False),
- 'next_sibling': relation(
+ 'next_sibling': relationship(
Node,
primaryjoin=node.c.next_sibling_id==node.c.id,
remote_side=node.c.id,
@@ -853,7 +853,7 @@ class SelfReferentialPostUpdateTest2(_base.MappedTest):
"""
mapper(A, a_table, properties={
- 'foo': relation(A,
+ 'foo': relationship(A,
remote_side=[a_table.c.id],
post_update=True)})
diff --git a/test/orm/test_defaults.py b/test/orm/test_defaults.py
index 0e7c6d08a..9be8e6e56 100644
--- a/test/orm/test_defaults.py
+++ b/test/orm/test_defaults.py
@@ -3,7 +3,7 @@ import sqlalchemy as sa
from sqlalchemy.test import testing
from sqlalchemy import Integer, String, ForeignKey
from sqlalchemy.test.schema import Table, Column
-from sqlalchemy.orm import mapper, relation, create_session
+from sqlalchemy.orm import mapper, relationship, create_session
from test.orm import _base
from sqlalchemy.test.testing import eq_
diff --git a/test/orm/test_deprecations.py b/test/orm/test_deprecations.py
index 00d64119e..76c59d029 100644
--- a/test/orm/test_deprecations.py
+++ b/test/orm/test_deprecations.py
@@ -9,7 +9,7 @@ from sqlalchemy.test import testing
from sqlalchemy import Integer, String, ForeignKey, func
from sqlalchemy.test.schema import Table
from sqlalchemy.test.schema import Column
-from sqlalchemy.orm import mapper, relation, create_session, sessionmaker
+from sqlalchemy.orm import mapper, relationship, relation, create_session, sessionmaker
from test.orm import _base
@@ -70,7 +70,7 @@ class QueryAlternativesTest(_base.MappedTest):
@testing.resolve_artifact_names
def setup_mappers(cls):
mapper(User, users_table, properties=dict(
- addresses=relation(Address, backref='user'),
+ addresses=relationship(Address, backref='user'),
))
mapper(Address, addresses_table)
@@ -483,4 +483,3 @@ class QueryAlternativesTest(_base.MappedTest):
users = session.query(User).filter("name='ed'").all()
assert len(users) == 1 and users[0].name == 'ed'
-
diff --git a/test/orm/test_dynamic.py b/test/orm/test_dynamic.py
index cc48bfde1..b2fac6005 100644
--- a/test/orm/test_dynamic.py
+++ b/test/orm/test_dynamic.py
@@ -4,7 +4,7 @@ from sqlalchemy.orm import dynamic_loader, backref
from sqlalchemy.test import testing
from sqlalchemy import Integer, String, ForeignKey, desc, select, func
from sqlalchemy.test.schema import Table, Column
-from sqlalchemy.orm import mapper, relation, create_session, Query, attributes
+from sqlalchemy.orm import mapper, relationship, create_session, Query, attributes
from sqlalchemy.orm.dynamic import AppenderMixin
from sqlalchemy.test.testing import eq_, AssertsCompiledSQL
from sqlalchemy.util import function_named
@@ -91,7 +91,7 @@ class DynamicTest(_fixtures.FixtureTest, AssertsCompiledSQL):
@testing.resolve_artifact_names
def test_backref(self):
mapper(Address, addresses, properties={
- 'user':relation(User, backref=backref('addresses', lazy='dynamic'))
+ 'user':relationship(User, backref=backref('addresses', lazy='dynamic'))
})
mapper(User, users)
@@ -125,7 +125,7 @@ class DynamicTest(_fixtures.FixtureTest, AssertsCompiledSQL):
@testing.resolve_artifact_names
def test_m2m(self):
mapper(Order, orders, properties={
- 'items':relation(Item, secondary=order_items, lazy="dynamic",
+ 'items':relationship(Item, secondary=order_items, lazy="dynamic",
backref=backref('orders', lazy="dynamic"))
})
mapper(Item, items)
@@ -143,7 +143,7 @@ class DynamicTest(_fixtures.FixtureTest, AssertsCompiledSQL):
@testing.resolve_artifact_names
def test_association_nonaliased(self):
mapper(Order, orders, properties={
- 'items':relation(Item, secondary=order_items,
+ 'items':relationship(Item, secondary=order_items,
lazy="dynamic",
order_by=order_items.c.item_id)
})
@@ -425,7 +425,7 @@ class SessionTest(_fixtures.FixtureTest):
sess.delete(u)
- # u.addresses relation will have to force the load
+ # u.addresses relationship will have to force the load
# of all addresses so that they can be updated
sess.flush()
sess.close()
@@ -461,7 +461,7 @@ class SessionTest(_fixtures.FixtureTest):
sess.delete(u)
- # u.addresses relation will have to force the load
+ # u.addresses relationship will have to force the load
# of all addresses so that they can be updated
sess.flush()
sess.close()
@@ -578,7 +578,7 @@ class DontDereferenceTest(_base.MappedTest):
pass
mapper(User, users, properties={
- 'addresses': relation(Address, backref='user', lazy='dynamic')
+ 'addresses': relationship(Address, backref='user', lazy='dynamic')
})
mapper(Address, addresses)
diff --git a/test/orm/test_eager_relations.py b/test/orm/test_eager_relations.py
index 88871426f..0411a22c8 100644
--- a/test/orm/test_eager_relations.py
+++ b/test/orm/test_eager_relations.py
@@ -6,7 +6,7 @@ from sqlalchemy.test import testing
from sqlalchemy.orm import eagerload, deferred, undefer, eagerload_all, backref
from sqlalchemy import Integer, String, Date, ForeignKey, and_, select, func
from sqlalchemy.test.schema import Table, Column
-from sqlalchemy.orm import mapper, relation, create_session, lazyload, aliased
+from sqlalchemy.orm import mapper, relationship, create_session, lazyload, aliased
from sqlalchemy.test.testing import eq_, assert_raises
from sqlalchemy.test.assertsql import CompiledSQL
from test.orm import _base, _fixtures
@@ -20,7 +20,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
@testing.resolve_artifact_names
def test_basic(self):
mapper(User, users, properties={
- 'addresses':relation(mapper(Address, addresses), lazy=False, order_by=Address.id)
+ 'addresses':relationship(mapper(Address, addresses), lazy=False, order_by=Address.id)
})
sess = create_session()
q = sess.query(User)
@@ -34,7 +34,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
m = mapper(User, users)
sess = create_session()
sess.query(User).all()
- m.add_property("addresses", relation(mapper(Address, addresses)))
+ m.add_property("addresses", relationship(mapper(Address, addresses)))
sess.expunge_all()
def go():
@@ -49,7 +49,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
def test_no_orphan(self):
"""An eagerly loaded child object is not marked as an orphan"""
mapper(User, users, properties={
- 'addresses':relation(Address, cascade="all,delete-orphan", lazy=False)
+ 'addresses':relationship(Address, cascade="all,delete-orphan", lazy=False)
})
mapper(Address, addresses)
@@ -61,7 +61,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
@testing.resolve_artifact_names
def test_orderby(self):
mapper(User, users, properties = {
- 'addresses':relation(mapper(Address, addresses), lazy=False, order_by=addresses.c.email_address),
+ 'addresses':relationship(mapper(Address, addresses), lazy=False, order_by=addresses.c.email_address),
})
q = create_session().query(User)
eq_([
@@ -82,7 +82,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
@testing.resolve_artifact_names
def test_orderby_multi(self):
mapper(User, users, properties = {
- 'addresses':relation(mapper(Address, addresses), lazy=False, order_by=[addresses.c.email_address, addresses.c.id]),
+ 'addresses':relationship(mapper(Address, addresses), lazy=False, order_by=[addresses.c.email_address, addresses.c.id]),
})
q = create_session().query(User)
eq_([
@@ -102,10 +102,10 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
@testing.resolve_artifact_names
def test_orderby_related(self):
- """A regular mapper select on a single table can order by a relation to a second table"""
+ """A regular mapper select on a single table can order by a relationship to a second table"""
mapper(Address, addresses)
mapper(User, users, properties = dict(
- addresses = relation(Address, lazy=False, order_by=addresses.c.id),
+ addresses = relationship(Address, lazy=False, order_by=addresses.c.id),
))
q = create_session().query(User)
@@ -129,7 +129,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
def test_orderby_desc(self):
mapper(Address, addresses)
mapper(User, users, properties = dict(
- addresses = relation(Address, lazy=False,
+ addresses = relationship(Address, lazy=False,
order_by=[sa.desc(addresses.c.email_address)]),
))
sess = create_session()
@@ -157,7 +157,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
mapper(Address, addresses, properties={
'user_id':deferred(addresses.c.user_id),
- 'user':relation(User, lazy=False)
+ 'user':relationship(User, lazy=False)
})
mapper(User, users)
@@ -200,7 +200,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
'user_id':deferred(addresses.c.user_id),
})
mapper(User, users, properties={
- 'addresses':relation(Address, lazy=False)})
+ 'addresses':relationship(Address, lazy=False)})
for q in [
sess.query(User).filter(User.id==7),
@@ -222,10 +222,10 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
sa.orm.clear_mappers()
mapper(User, users, properties={
- 'addresses':relation(Address, lazy=False)})
+ 'addresses':relationship(Address, lazy=False)})
mapper(Address, addresses, properties={
'user_id':deferred(addresses.c.user_id),
- 'dingalings':relation(Dingaling, lazy=False)})
+ 'dingalings':relationship(Dingaling, lazy=False)})
mapper(Dingaling, dingalings, properties={
'address_id':deferred(dingalings.c.address_id)})
sess.expunge_all()
@@ -246,7 +246,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
mapper(Keyword, keywords)
mapper(Item, items, properties = dict(
- keywords = relation(Keyword, secondary=item_keywords,
+ keywords = relationship(Keyword, secondary=item_keywords,
lazy=False, order_by=keywords.c.id)))
q = create_session().query(Item).order_by(Item.id)
@@ -273,7 +273,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
mapper(Keyword, keywords)
mapper(Item, items, properties = dict(
- keywords = relation(Keyword, secondary=item_keywords, lazy=True,
+ keywords = relationship(Keyword, secondary=item_keywords, lazy=True,
order_by=keywords.c.id)))
q = create_session().query(Item)
@@ -293,7 +293,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
mapper(Address, addresses)
mapper(User, users, properties = dict(
- addresses = relation(Address, lazy=False,
+ addresses = relationship(Address, lazy=False,
backref=sa.orm.backref('user', lazy=False), order_by=Address.id)
))
is_(sa.orm.class_mapper(User).get_property('addresses').lazy, False)
@@ -304,7 +304,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
@testing.resolve_artifact_names
def test_double(self):
- """Eager loading with two relations simultaneously, from the same table, using aliases."""
+ """Eager loading with two relationships simultaneously, from the same table, using aliases."""
User, Address, Order = self.classes.get_all(
'User', 'Address', 'Order')
users, addresses, orders = self.tables.get_all(
@@ -320,13 +320,13 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
closed_mapper = mapper(Order, closedorders, non_primary=True)
mapper(User, users, properties = dict(
- addresses = relation(Address, lazy=False, order_by=addresses.c.id),
- open_orders = relation(
+ addresses = relationship(Address, lazy=False, order_by=addresses.c.id),
+ open_orders = relationship(
open_mapper,
primaryjoin=sa.and_(openorders.c.isopen == 1,
users.c.id==openorders.c.user_id),
lazy=False, order_by=openorders.c.id),
- closed_orders = relation(
+ closed_orders = relationship(
closed_mapper,
primaryjoin=sa.and_(closedorders.c.isopen == 0,
users.c.id==closedorders.c.user_id),
@@ -361,7 +361,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
@testing.resolve_artifact_names
def test_double_same_mappers(self):
- """Eager loading with two relations simulatneously, from the same table, using aliases."""
+ """Eager loading with two relationships simulatneously, from the same table, using aliases."""
User, Address, Order = self.classes.get_all(
'User', 'Address', 'Order')
users, addresses, orders = self.tables.get_all(
@@ -369,17 +369,17 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
mapper(Address, addresses)
mapper(Order, orders, properties={
- 'items': relation(Item, secondary=order_items, lazy=False,
+ 'items': relationship(Item, secondary=order_items, lazy=False,
order_by=items.c.id)})
mapper(Item, items)
mapper(User, users, properties=dict(
- addresses=relation(Address, lazy=False, order_by=addresses.c.id),
- open_orders=relation(
+ addresses=relationship(Address, lazy=False, order_by=addresses.c.id),
+ open_orders=relationship(
Order,
primaryjoin=sa.and_(orders.c.isopen == 1,
users.c.id==orders.c.user_id),
lazy=False, order_by=orders.c.id),
- closed_orders=relation(
+ closed_orders=relationship(
Order,
primaryjoin=sa.and_(orders.c.isopen == 0,
users.c.id==orders.c.user_id),
@@ -438,8 +438,8 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
'users', 'addresses', 'orders')
mapper(User, users, properties={
- 'addresses':relation(Address, lazy=False),
- 'orders':relation(Order, lazy=False)
+ 'addresses':relationship(Address, lazy=False),
+ 'orders':relationship(Order, lazy=False)
})
mapper(Address, addresses)
mapper(Order, orders)
@@ -465,11 +465,11 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
mapper(Item, items)
mapper(Order, orders, properties={
- 'items':relation(Item, secondary=order_items, lazy=False, order_by=items.c.id)
+ 'items':relationship(Item, secondary=order_items, lazy=False, order_by=items.c.id)
})
mapper(User, users, properties={
- 'addresses':relation(mapper(Address, addresses), lazy=False, order_by=addresses.c.id),
- 'orders':relation(Order, lazy=True, order_by=orders.c.id)
+ 'addresses':relationship(mapper(Address, addresses), lazy=False, order_by=addresses.c.id),
+ 'orders':relationship(Order, lazy=True, order_by=orders.c.id)
})
sess = create_session()
@@ -487,7 +487,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
s = sa.union_all(u2.select(use_labels=True), u2.select(use_labels=True), u2.select(use_labels=True)).alias('u')
mapper(User, users, properties={
- 'addresses':relation(mapper(Address, addresses), lazy=False, order_by=addresses.c.id),
+ 'addresses':relationship(mapper(Address, addresses), lazy=False, order_by=addresses.c.id),
})
sess = create_session()
@@ -503,7 +503,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
def test_limit_2(self):
mapper(Keyword, keywords)
mapper(Item, items, properties = dict(
- keywords = relation(Keyword, secondary=item_keywords, lazy=False, order_by=[keywords.c.id]),
+ keywords = relationship(Keyword, secondary=item_keywords, lazy=False, order_by=[keywords.c.id]),
))
sess = create_session()
@@ -521,13 +521,13 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
mapper(Item, items)
mapper(Order, orders, properties = dict(
- items = relation(Item, secondary=order_items, lazy=False)
+ items = relationship(Item, secondary=order_items, lazy=False)
))
mapper(Address, addresses)
mapper(User, users, properties = dict(
- addresses = relation(Address, lazy=False, order_by=addresses.c.id),
- orders = relation(Order, lazy=False, order_by=orders.c.id),
+ addresses = relationship(Address, lazy=False, order_by=addresses.c.id),
+ orders = relationship(Order, lazy=False, order_by=orders.c.id),
))
sess = create_session()
@@ -560,7 +560,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
sel = sa.select([users, addresses.c.email_address],
users.c.id==addresses.c.user_id).alias('useralias')
mapper(User, sel, properties={
- 'orders':relation(Order, primaryjoin=sel.c.id==orders.c.user_id, lazy=False)
+ 'orders':relationship(Order, primaryjoin=sel.c.id==orders.c.user_id, lazy=False)
})
mapper(Order, orders)
@@ -578,11 +578,11 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
"""test that the subquery wrapping only occurs with limit/offset and m2m or o2m joins present."""
mapper(User, users, properties=odict(
- orders=relation(Order, backref='user')
+ orders=relationship(Order, backref='user')
))
mapper(Order, orders, properties=odict(
- items=relation(Item, secondary=order_items, backref='orders'),
- address=relation(Address)
+ items=relationship(Item, secondary=order_items, backref='orders'),
+ address=relationship(Address)
))
mapper(Address, addresses)
mapper(Item, items)
@@ -663,7 +663,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
@testing.resolve_artifact_names
def test_one_to_many_scalar(self):
mapper(User, users, properties = dict(
- address = relation(mapper(Address, addresses), lazy=False, uselist=False)
+ address = relationship(mapper(Address, addresses), lazy=False, uselist=False)
))
q = create_session().query(User)
@@ -676,7 +676,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
@testing.resolve_artifact_names
def test_many_to_one(self):
mapper(Address, addresses, properties = dict(
- user = relation(mapper(User, users), lazy=False)
+ user = relationship(mapper(User, users), lazy=False)
))
sess = create_session()
q = sess.query(Address)
@@ -698,7 +698,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
# use a primaryjoin intended to defeat SA's usage of
# query.get() for a many-to-one lazyload
mapper(Order, orders, properties = dict(
- address = relation(mapper(Address, addresses),
+ address = relationship(mapper(Address, addresses),
primaryjoin=and_(
addresses.c.id==orders.c.address_id,
addresses.c.email_address != None
@@ -725,11 +725,11 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
contains a many-to-many relationship to a third object."""
mapper(User, users, properties={
- 'orders':relation(Order, lazy=False, order_by=orders.c.id)
+ 'orders':relationship(Order, lazy=False, order_by=orders.c.id)
})
mapper(Item, items)
mapper(Order, orders, properties = dict(
- items = relation(Item, secondary=order_items, lazy=False, order_by=items.c.id)
+ items = relationship(Item, secondary=order_items, lazy=False, order_by=items.c.id)
))
q = create_session().query(User)
@@ -749,8 +749,8 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
mapper(Order, orders)
mapper(User, users, properties={
- 'orders':relation(Order, backref='user', lazy=False, order_by=orders.c.id),
- 'max_order':relation(
+ 'orders':relationship(Order, backref='user', lazy=False, order_by=orders.c.id),
+ 'max_order':relationship(
mapper(Order, max_orders, non_primary=True),
lazy=False, uselist=False)
})
@@ -779,7 +779,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
"""test that multiple rows received by a uselist=False raises a warning."""
mapper(User, users, properties={
- 'order':relation(Order, uselist=False)
+ 'order':relationship(Order, uselist=False)
})
mapper(Order, orders)
s = create_session()
@@ -787,12 +787,12 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
@testing.resolve_artifact_names
def test_wide(self):
- mapper(Order, orders, properties={'items':relation(Item, secondary=order_items, lazy=False,
+ mapper(Order, orders, properties={'items':relationship(Item, secondary=order_items, lazy=False,
order_by=items.c.id)})
mapper(Item, items)
mapper(User, users, properties = dict(
- addresses = relation(mapper(Address, addresses), lazy = False, order_by=addresses.c.id),
- orders = relation(Order, lazy = False, order_by=orders.c.id),
+ addresses = relationship(mapper(Address, addresses), lazy = False, order_by=addresses.c.id),
+ orders = relationship(Order, lazy = False, order_by=orders.c.id),
))
q = create_session().query(User)
l = q.all()
@@ -805,7 +805,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
s = sa.select([orders], orders.c.isopen==1).alias('openorders')
mapper(Order, s, properties={
- 'user':relation(User, lazy=False)
+ 'user':relationship(User, lazy=False)
})
mapper(User, users)
mapper(Item, items)
@@ -826,7 +826,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
"""test that eager loading uses aliases to insulate the eager load from regular criterion against those tables."""
mapper(User, users, properties = dict(
- addresses = relation(mapper(Address, addresses), lazy=False, order_by=addresses.c.id)
+ addresses = relationship(mapper(Address, addresses), lazy=False, order_by=addresses.c.id)
))
q = create_session().query(User)
l = q.filter(addresses.c.email_address == 'ed@lala.com').filter(
@@ -836,7 +836,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
@testing.resolve_artifact_names
def test_inner_join(self):
mapper(User, users, properties = dict(
- addresses = relation(mapper(Address, addresses), lazy=False, innerjoin=True, order_by=addresses.c.id)
+ addresses = relationship(mapper(Address, addresses), lazy=False, innerjoin=True, order_by=addresses.c.id)
))
sess = create_session()
eq_(
@@ -858,10 +858,10 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
@testing.resolve_artifact_names
def test_inner_join_options(self):
mapper(User, users, properties = dict(
- orders =relation(Order, backref=backref('user', innerjoin=True), order_by=orders.c.id)
+ orders =relationship(Order, backref=backref('user', innerjoin=True), order_by=orders.c.id)
))
mapper(Order, orders, properties=dict(
- items=relation(Item, secondary=order_items, order_by=items.c.id)
+ items=relationship(Item, secondary=order_items, order_by=items.c.id)
))
mapper(Item, items)
sess = create_session()
@@ -964,12 +964,12 @@ class AddEntityTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_mapper_configured(self):
mapper(User, users, properties={
- 'addresses':relation(Address, lazy=False),
- 'orders':relation(Order)
+ 'addresses':relationship(Address, lazy=False),
+ 'orders':relationship(Order)
})
mapper(Address, addresses)
mapper(Order, orders, properties={
- 'items':relation(Item, secondary=order_items, lazy=False, order_by=items.c.id)
+ 'items':relationship(Item, secondary=order_items, lazy=False, order_by=items.c.id)
})
mapper(Item, items)
@@ -985,12 +985,12 @@ class AddEntityTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_options(self):
mapper(User, users, properties={
- 'addresses':relation(Address),
- 'orders':relation(Order)
+ 'addresses':relationship(Address),
+ 'orders':relationship(Order)
})
mapper(Address, addresses)
mapper(Order, orders, properties={
- 'items':relation(Item, secondary=order_items, order_by=items.c.id)
+ 'items':relationship(Item, secondary=order_items, order_by=items.c.id)
})
mapper(Item, items)
@@ -1053,7 +1053,7 @@ class OrderBySecondaryTest(_base.MappedTest):
class B(_base.ComparableEntity):pass
mapper(A, a, properties={
- 'bs':relation(B, secondary=m2m, lazy=False, order_by=m2m.c.id)
+ 'bs':relationship(B, secondary=m2m, lazy=False, order_by=m2m.c.id)
})
mapper(B, b)
@@ -1078,7 +1078,7 @@ class SelfReferentialEagerTest(_base.MappedTest):
self.children.append(node)
mapper(Node, nodes, properties={
- 'children':relation(Node, lazy=False, join_depth=3, order_by=nodes.c.id)
+ 'children':relationship(Node, lazy=False, join_depth=3, order_by=nodes.c.id)
})
sess = create_session()
n1 = Node(data='n1')
@@ -1126,7 +1126,7 @@ class SelfReferentialEagerTest(_base.MappedTest):
self.children.append(node)
mapper(Node, nodes, properties={
- 'children':relation(Node, lazy=False, join_depth=1, order_by=nodes.c.id)
+ 'children':relationship(Node, lazy=False, join_depth=1, order_by=nodes.c.id)
})
sess = create_session()
n1 = Node(data='n1')
@@ -1166,7 +1166,7 @@ class SelfReferentialEagerTest(_base.MappedTest):
self.children.append(node)
mapper(Node, nodes, properties={
- 'children':relation(Node, lazy=False, join_depth=3, order_by=nodes.c.id),
+ 'children':relationship(Node, lazy=False, join_depth=3, order_by=nodes.c.id),
'data':deferred(nodes.c.data)
})
sess = create_session()
@@ -1206,7 +1206,7 @@ class SelfReferentialEagerTest(_base.MappedTest):
self.children.append(node)
mapper(Node, nodes, properties={
- 'children':relation(Node, lazy=True, order_by=nodes.c.id)
+ 'children':relationship(Node, lazy=True, order_by=nodes.c.id)
}, order_by=nodes.c.id)
sess = create_session()
n1 = Node(data='n1')
@@ -1252,7 +1252,7 @@ class SelfReferentialEagerTest(_base.MappedTest):
self.children.append(node)
mapper(Node, nodes, properties={
- 'children':relation(Node, lazy=False)
+ 'children':relationship(Node, lazy=False)
})
sess = create_session()
n1 = Node(data='n1')
@@ -1302,13 +1302,13 @@ class MixedSelfReferentialEagerTest(_base.MappedTest):
mapper(A,a_table)
mapper(B,b_table,properties = {
- 'parent_b1': relation(B,
+ 'parent_b1': relationship(B,
remote_side = [b_table.c.id],
primaryjoin = (b_table.c.parent_b1_id ==b_table.c.id),
order_by = b_table.c.id
),
- 'parent_z': relation(A,lazy = True),
- 'parent_b2': relation(B,
+ 'parent_z': relationship(A,lazy = True),
+ 'parent_b2': relationship(B,
remote_side = [b_table.c.id],
primaryjoin = (b_table.c.parent_b2_id ==b_table.c.id),
order_by = b_table.c.id
@@ -1371,7 +1371,7 @@ class SelfReferentialM2MEagerTest(_base.MappedTest):
pass
mapper(Widget, widget, properties={
- 'children': relation(Widget, secondary=widget_rel,
+ 'children': relationship(Widget, secondary=widget_rel,
primaryjoin=widget_rel.c.parent_id==widget.c.id,
secondaryjoin=widget_rel.c.child_id==widget.c.id,
lazy=False, join_depth=1,
@@ -1398,15 +1398,15 @@ class MixedEntitiesTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):
@testing.resolve_artifact_names
def setup_mappers(cls):
mapper(User, users, properties={
- 'addresses':relation(Address, backref='user'),
- 'orders':relation(Order, backref='user'), # o2m, m2o
+ 'addresses':relationship(Address, backref='user'),
+ 'orders':relationship(Order, backref='user'), # o2m, m2o
})
mapper(Address, addresses)
mapper(Order, orders, properties={
- 'items':relation(Item, secondary=order_items, order_by=items.c.id), #m2m
+ 'items':relationship(Item, secondary=order_items, order_by=items.c.id), #m2m
})
mapper(Item, items, properties={
- 'keywords':relation(Keyword, secondary=item_keywords) #m2m
+ 'keywords':relationship(Keyword, secondary=item_keywords) #m2m
})
mapper(Keyword, keywords)
@@ -1559,7 +1559,7 @@ class CyclicalInheritingEagerTest(_base.MappedTest):
mapper(T, t1, polymorphic_on=t1.c.type, polymorphic_identity='t1')
mapper(SubT, None, inherits=T, polymorphic_identity='subt1', properties={
- 't2s':relation(SubT2, lazy=False, backref=sa.orm.backref('subt', lazy=False))
+ 't2s':relationship(SubT2, lazy=False, backref=sa.orm.backref('subt', lazy=False))
})
mapper(T2, t2, polymorphic_on=t2.c.type, polymorphic_identity='t2')
mapper(SubT2, None, inherits=T2, polymorphic_identity='subt2')
@@ -1626,7 +1626,7 @@ class SubqueryTest(_base.MappedTest):
mapper(User, users_table, properties={
- 'tags': relation(Tag, backref='user', lazy=False),
+ 'tags': relationship(Tag, backref='user', lazy=False),
'query_score': sa.orm.column_property(user_score),
})
@@ -1650,7 +1650,7 @@ class SubqueryTest(_base.MappedTest):
class CorrelatedSubqueryTest(_base.MappedTest):
"""tests for #946, #947, #948.
- The "users" table is joined to "stuff", and the relation
+ The "users" table is joined to "stuff", and the relationship
would like to pull only the "stuff" entry with the most recent date.
Exercises a variety of ways to configure this.
@@ -1763,11 +1763,11 @@ class CorrelatedSubqueryTest(_base.MappedTest):
if ondate:
mapper(User, users, properties={
- 'stuff':relation(Stuff, primaryjoin=and_(users.c.id==stuff.c.user_id, stuff.c.date==stuff_view))
+ 'stuff':relationship(Stuff, primaryjoin=and_(users.c.id==stuff.c.user_id, stuff.c.date==stuff_view))
})
else:
mapper(User, users, properties={
- 'stuff':relation(Stuff, primaryjoin=and_(users.c.id==stuff.c.user_id, stuff.c.id==stuff_view))
+ 'stuff':relationship(Stuff, primaryjoin=and_(users.c.id==stuff.c.user_id, stuff.c.id==stuff_view))
})
sess = create_session()
diff --git a/test/orm/test_expire.py b/test/orm/test_expire.py
index 021d757fe..e801fe6e8 100644
--- a/test/orm/test_expire.py
+++ b/test/orm/test_expire.py
@@ -7,7 +7,7 @@ from sqlalchemy.test import testing
from sqlalchemy import Integer, String, ForeignKey, exc as sa_exc
from sqlalchemy.test.schema import Table
from sqlalchemy.test.schema import Column
-from sqlalchemy.orm import mapper, relation, create_session, \
+from sqlalchemy.orm import mapper, relationship, create_session, \
attributes, deferred, exc as orm_exc, defer, undefer,\
strategies, state, lazyload
from test.orm import _base, _fixtures
@@ -18,7 +18,7 @@ class ExpireTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_expire(self):
mapper(User, users, properties={
- 'addresses':relation(Address, backref='user'),
+ 'addresses':relationship(Address, backref='user'),
})
mapper(Address, addresses)
@@ -122,7 +122,7 @@ class ExpireTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_lazyload_autoflushes(self):
mapper(User, users, properties={
- 'addresses':relation(Address, order_by=addresses.c.email_address)
+ 'addresses':relationship(Address, order_by=addresses.c.email_address)
})
mapper(Address, addresses)
s = create_session(autoflush=True, autocommit=False)
@@ -147,7 +147,7 @@ class ExpireTest(_fixtures.FixtureTest):
"""test graceful failure for currently unsupported immediate refresh of a collection"""
mapper(User, users, properties={
- 'addresses':relation(Address, order_by=addresses.c.email_address)
+ 'addresses':relationship(Address, order_by=addresses.c.email_address)
})
mapper(Address, addresses)
s = create_session(autoflush=True, autocommit=False)
@@ -286,7 +286,7 @@ class ExpireTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_expire_cascade(self):
mapper(User, users, properties={
- 'addresses':relation(Address, cascade="all, refresh-expire")
+ 'addresses':relationship(Address, cascade="all, refresh-expire")
})
mapper(Address, addresses)
s = create_session()
@@ -302,7 +302,7 @@ class ExpireTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_expired_lazy(self):
mapper(User, users, properties={
- 'addresses':relation(Address, backref='user'),
+ 'addresses':relationship(Address, backref='user'),
})
mapper(Address, addresses)
@@ -324,7 +324,7 @@ class ExpireTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_expired_eager(self):
mapper(User, users, properties={
- 'addresses':relation(Address, backref='user', lazy=False),
+ 'addresses':relationship(Address, backref='user', lazy=False),
})
mapper(Address, addresses)
@@ -338,7 +338,7 @@ class ExpireTest(_fixtures.FixtureTest):
def go():
assert u.addresses[0].email_address == 'jack@bean.com'
assert u.name == 'jack'
- # two loads, since relation() + scalar are
+ # two loads, since relationship() + scalar are
# separate right now on per-attribute load
self.assert_sql_count(testing.db, go, 2)
assert 'name' in u.__dict__
@@ -352,14 +352,14 @@ class ExpireTest(_fixtures.FixtureTest):
sess.query(User).filter_by(id=7).one()
assert u.addresses[0].email_address == 'jack@bean.com'
assert u.name == 'jack'
- # one load, since relation() + scalar are
+ # one load, since relationship() + scalar are
# together when eager load used with Query
self.assert_sql_count(testing.db, go, 1)
@testing.resolve_artifact_names
- def test_relation_changes_preserved(self):
+ def test_relationship_changes_preserved(self):
mapper(User, users, properties={
- 'addresses':relation(Address, backref='user', lazy=False),
+ 'addresses':relationship(Address, backref='user', lazy=False),
})
mapper(Address, addresses)
sess = create_session()
@@ -374,7 +374,7 @@ class ExpireTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_eagerload_props_dontload(self):
- # relations currently have to load separately from scalar instances.
+ # relationships currently have to load separately from scalar instances.
# the use case is: expire "addresses". then access it. lazy load
# fires off to load "addresses", but needs foreign key or primary key
# attributes in order to lazy load; hits those attributes, such as
@@ -385,7 +385,7 @@ class ExpireTest(_fixtures.FixtureTest):
# "figure out" that the operation should be aborted right now.
mapper(User, users, properties={
- 'addresses':relation(Address, backref='user', lazy=False),
+ 'addresses':relationship(Address, backref='user', lazy=False),
})
mapper(Address, addresses)
sess = create_session()
@@ -469,7 +469,7 @@ class ExpireTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_partial_expire_lazy(self):
mapper(User, users, properties={
- 'addresses':relation(Address, backref='user'),
+ 'addresses':relationship(Address, backref='user'),
})
mapper(Address, addresses)
@@ -514,7 +514,7 @@ class ExpireTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_partial_expire_eager(self):
mapper(User, users, properties={
- 'addresses':relation(Address, backref='user', lazy=False),
+ 'addresses':relationship(Address, backref='user', lazy=False),
})
mapper(Address, addresses)
@@ -553,9 +553,9 @@ class ExpireTest(_fixtures.FixtureTest):
#self.assert_sql_count(testing.db, go, 0)
@testing.resolve_artifact_names
- def test_relations_load_on_query(self):
+ def test_relationships_load_on_query(self):
mapper(User, users, properties={
- 'addresses':relation(Address, backref='user'),
+ 'addresses':relationship(Address, backref='user'),
})
mapper(Address, addresses)
@@ -643,7 +643,7 @@ class ExpireTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_eagerload_query_refreshes(self):
mapper(User, users, properties={
- 'addresses':relation(Address, backref='user', lazy=False),
+ 'addresses':relationship(Address, backref='user', lazy=False),
})
mapper(Address, addresses)
@@ -660,7 +660,7 @@ class ExpireTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_expire_all(self):
mapper(User, users, properties={
- 'addresses':relation(Address, backref='user', lazy=False),
+ 'addresses':relationship(Address, backref='user', lazy=False),
})
mapper(Address, addresses)
@@ -768,7 +768,7 @@ class ExpireTest(_fixtures.FixtureTest):
def test_state_noload_to_lazy(self):
"""Behavioral test to verify the current activity of loader callables."""
- mapper(User, users, properties={'addresses':relation(Address, lazy=None)})
+ mapper(User, users, properties={'addresses':relationship(Address, lazy=None)})
mapper(Address, addresses)
sess = create_session()
@@ -890,7 +890,7 @@ class ExpiredPendingTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_expired_pending(self):
mapper(User, users, properties={
- 'addresses':relation(Address, backref='user'),
+ 'addresses':relationship(Address, backref='user'),
})
mapper(Address, addresses)
@@ -932,7 +932,7 @@ class RefreshTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_refresh(self):
mapper(User, users, properties={
- 'addresses':relation(mapper(Address, addresses), backref='user')
+ 'addresses':relationship(mapper(Address, addresses), backref='user')
})
s = create_session()
u = s.query(User).get(7)
@@ -990,7 +990,7 @@ class RefreshTest(_fixtures.FixtureTest):
fire the lazy loader or create any problems"""
s = create_session()
- mapper(User, users, properties={'addresses':relation(mapper(Address, addresses))})
+ mapper(User, users, properties={'addresses':relationship(mapper(Address, addresses))})
q = s.query(User).options(sa.orm.lazyload('addresses'))
u = q.filter(users.c.id==8).first()
def go():
@@ -1002,7 +1002,7 @@ class RefreshTest(_fixtures.FixtureTest):
"""test that a refresh/expire operation loads rows properly and sends correct "isnew" state to eager loaders"""
mapper(User, users, properties={
- 'addresses':relation(mapper(Address, addresses), lazy=False)
+ 'addresses':relationship(mapper(Address, addresses), lazy=False)
})
s = create_session()
@@ -1025,7 +1025,7 @@ class RefreshTest(_fixtures.FixtureTest):
s = create_session()
mapper(Address, addresses)
- mapper(User, users, properties = dict(addresses=relation(Address,cascade="all, delete-orphan",lazy=False)) )
+ mapper(User, users, properties = dict(addresses=relationship(Address,cascade="all, delete-orphan",lazy=False)) )
u = User()
u.name='Justin'
diff --git a/test/orm/test_generative.py b/test/orm/test_generative.py
index b077bcf70..141fde9fc 100644
--- a/test/orm/test_generative.py
+++ b/test/orm/test_generative.py
@@ -4,7 +4,7 @@ from sqlalchemy.test import testing
from sqlalchemy import Integer, String, ForeignKey, MetaData, func
from sqlalchemy.test.schema import Table
from sqlalchemy.test.schema import Column
-from sqlalchemy.orm import mapper, relation, create_session
+from sqlalchemy.orm import mapper, relationship, create_session
from sqlalchemy.test.testing import eq_
from test.orm import _base, _fixtures
@@ -199,7 +199,7 @@ class GenerativeTest2(_base.MappedTest):
eq_(res.count(), 1)
-class RelationsTest(_fixtures.FixtureTest):
+class RelationshipsTest(_fixtures.FixtureTest):
run_setup_mappers = 'once'
run_inserts = 'once'
run_deletes = None
@@ -208,8 +208,8 @@ class RelationsTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def setup_mappers(cls):
mapper(User, users, properties={
- 'orders':relation(mapper(Order, orders, properties={
- 'addresses':relation(mapper(Address, addresses))}))})
+ 'orders':relationship(mapper(Order, orders, properties={
+ 'addresses':relationship(mapper(Address, addresses))}))})
@testing.resolve_artifact_names
diff --git a/test/orm/test_instrumentation.py b/test/orm/test_instrumentation.py
index 6390e2596..b0c965470 100644
--- a/test/orm/test_instrumentation.py
+++ b/test/orm/test_instrumentation.py
@@ -4,7 +4,7 @@ import sqlalchemy as sa
from sqlalchemy import MetaData, Integer, ForeignKey, util
from sqlalchemy.test.schema import Table
from sqlalchemy.test.schema import Column
-from sqlalchemy.orm import mapper, relation, create_session, attributes, class_mapper, clear_mappers
+from sqlalchemy.orm import mapper, relationship, create_session, attributes, class_mapper, clear_mappers
from sqlalchemy.test.testing import eq_, ne_
from sqlalchemy.util import function_named
from test.orm import _base
@@ -649,7 +649,7 @@ class MiscTest(_base.ORMTest):
Column('t1_id', Integer, ForeignKey('t1.id')))
class A(object): pass
class B(object): pass
- mapper(A, t1, properties=dict(bs=relation(B)))
+ mapper(A, t1, properties=dict(bs=relationship(B)))
mapper(B, t2)
a = A()
@@ -680,7 +680,7 @@ class MiscTest(_base.ORMTest):
for base in object, Base:
class A(base): pass
class B(base): pass
- mapper(A, t1, properties=dict(bs=relation(B, backref='a')))
+ mapper(A, t1, properties=dict(bs=relationship(B, backref='a')))
mapper(B, t2)
b = B()
@@ -710,7 +710,7 @@ class MiscTest(_base.ORMTest):
class A(base): pass
class B(base): pass
mapper(A, t1)
- mapper(B, t2, properties=dict(a=relation(A, backref='bs')))
+ mapper(B, t2, properties=dict(a=relationship(A, backref='bs')))
a = A()
b = B()
diff --git a/test/orm/test_lazy_relations.py b/test/orm/test_lazy_relations.py
index ac175c83b..502747bfd 100644
--- a/test/orm/test_lazy_relations.py
+++ b/test/orm/test_lazy_relations.py
@@ -10,7 +10,7 @@ from sqlalchemy import Integer, String, ForeignKey, SmallInteger
from sqlalchemy.types import TypeDecorator
from sqlalchemy.test.schema import Table
from sqlalchemy.test.schema import Column
-from sqlalchemy.orm import mapper, relation, create_session
+from sqlalchemy.orm import mapper, relationship, create_session
from sqlalchemy.test.testing import eq_
from test.orm import _base, _fixtures
@@ -22,7 +22,7 @@ class LazyTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_basic(self):
mapper(User, users, properties={
- 'addresses':relation(mapper(Address, addresses), lazy=True)
+ 'addresses':relationship(mapper(Address, addresses), lazy=True)
})
sess = create_session()
q = sess.query(User)
@@ -33,7 +33,7 @@ class LazyTest(_fixtures.FixtureTest):
"""test the error raised when parent object is not bound."""
mapper(User, users, properties={
- 'addresses':relation(mapper(Address, addresses), lazy=True)
+ 'addresses':relationship(mapper(Address, addresses), lazy=True)
})
sess = create_session()
q = sess.query(User)
@@ -44,7 +44,7 @@ class LazyTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_orderby(self):
mapper(User, users, properties = {
- 'addresses':relation(mapper(Address, addresses), lazy=True, order_by=addresses.c.email_address),
+ 'addresses':relationship(mapper(Address, addresses), lazy=True, order_by=addresses.c.email_address),
})
q = create_session().query(User)
assert [
@@ -64,12 +64,12 @@ class LazyTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_orderby_secondary(self):
- """tests that a regular mapper select on a single table can order by a relation to a second table"""
+ """tests that a regular mapper select on a single table can order by a relationship to a second table"""
mapper(Address, addresses)
mapper(User, users, properties = dict(
- addresses = relation(Address, lazy=True),
+ addresses = relationship(Address, lazy=True),
))
q = create_session().query(User)
l = q.filter(users.c.id==addresses.c.user_id).order_by(addresses.c.email_address).all()
@@ -92,7 +92,7 @@ class LazyTest(_fixtures.FixtureTest):
mapper(Address, addresses)
mapper(User, users, properties = dict(
- addresses = relation(Address, lazy=True, order_by=[sa.desc(addresses.c.email_address)]),
+ addresses = relationship(Address, lazy=True, order_by=[sa.desc(addresses.c.email_address)]),
))
sess = create_session()
assert [
@@ -115,7 +115,7 @@ class LazyTest(_fixtures.FixtureTest):
"""test that a lazily loaded child object is not marked as an orphan"""
mapper(User, users, properties={
- 'addresses':relation(Address, cascade="all,delete-orphan", lazy=True)
+ 'addresses':relationship(Address, cascade="all,delete-orphan", lazy=True)
})
mapper(Address, addresses)
@@ -130,11 +130,11 @@ class LazyTest(_fixtures.FixtureTest):
mapper(Item, items)
mapper(Order, orders, properties={
- 'items':relation(Item, secondary=order_items, lazy=True)
+ 'items':relationship(Item, secondary=order_items, lazy=True)
})
mapper(User, users, properties={
- 'addresses':relation(mapper(Address, addresses), lazy=True),
- 'orders':relation(Order, lazy=True)
+ 'addresses':relationship(mapper(Address, addresses), lazy=True),
+ 'orders':relationship(Order, lazy=True)
})
sess = create_session()
@@ -151,11 +151,11 @@ class LazyTest(_fixtures.FixtureTest):
def test_distinct(self):
mapper(Item, items)
mapper(Order, orders, properties={
- 'items':relation(Item, secondary=order_items, lazy=True)
+ 'items':relationship(Item, secondary=order_items, lazy=True)
})
mapper(User, users, properties={
- 'addresses':relation(mapper(Address, addresses), lazy=True),
- 'orders':relation(Order, lazy=True)
+ 'addresses':relationship(mapper(Address, addresses), lazy=True),
+ 'orders':relationship(Order, lazy=True)
})
sess = create_session()
@@ -172,7 +172,7 @@ class LazyTest(_fixtures.FixtureTest):
"""test that multiple rows received by a uselist=False raises a warning."""
mapper(User, users, properties={
- 'order':relation(Order, uselist=False)
+ 'order':relationship(Order, uselist=False)
})
mapper(Order, orders)
s = create_session()
@@ -182,7 +182,7 @@ class LazyTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_one_to_many_scalar(self):
mapper(User, users, properties = dict(
- address = relation(mapper(Address, addresses), lazy=True, uselist=False)
+ address = relationship(mapper(Address, addresses), lazy=True, uselist=False)
))
q = create_session().query(User)
l = q.filter(users.c.id == 7).all()
@@ -193,7 +193,7 @@ class LazyTest(_fixtures.FixtureTest):
mapper(Address, addresses, primary_key=[addresses.c.user_id, addresses.c.email_address])
mapper(User, users, properties = dict(
- address = relation(Address, uselist=False,
+ address = relationship(Address, uselist=False,
primaryjoin=sa.and_(users.c.id==addresses.c.user_id, addresses.c.email_address=='ed@bettyboop.com')
)
))
@@ -211,7 +211,7 @@ class LazyTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_double(self):
- """tests lazy loading with two relations simulatneously, from the same table, using aliases. """
+ """tests lazy loading with two relationships simulatneously, from the same table, using aliases. """
openorders = sa.alias(orders, 'openorders')
closedorders = sa.alias(orders, 'closedorders')
@@ -223,9 +223,9 @@ class LazyTest(_fixtures.FixtureTest):
open_mapper = mapper(Order, openorders, non_primary=True)
closed_mapper = mapper(Order, closedorders, non_primary=True)
mapper(User, users, properties = dict(
- addresses = relation(Address, lazy = True),
- open_orders = relation(open_mapper, primaryjoin = sa.and_(openorders.c.isopen == 1, users.c.id==openorders.c.user_id), lazy=True),
- closed_orders = relation(closed_mapper, primaryjoin = sa.and_(closedorders.c.isopen == 0, users.c.id==closedorders.c.user_id), lazy=True)
+ addresses = relationship(Address, lazy = True),
+ open_orders = relationship(open_mapper, primaryjoin = sa.and_(openorders.c.isopen == 1, users.c.id==openorders.c.user_id), lazy=True),
+ closed_orders = relationship(closed_mapper, primaryjoin = sa.and_(closedorders.c.isopen == 0, users.c.id==closedorders.c.user_id), lazy=True)
))
q = create_session().query(User)
@@ -262,7 +262,7 @@ class LazyTest(_fixtures.FixtureTest):
mapper(Keyword, keywords)
mapper(Item, items, properties = dict(
- keywords = relation(Keyword, secondary=item_keywords, lazy=True),
+ keywords = relationship(Keyword, secondary=item_keywords, lazy=True),
))
q = create_session().query(Item)
@@ -280,7 +280,7 @@ class LazyTest(_fixtures.FixtureTest):
addresses.c.user_id==users.c.id
):
mapper(Address, addresses, properties = dict(
- user = relation(mapper(User, users), lazy=True, primaryjoin=pj)
+ user = relationship(mapper(User, users), lazy=True, primaryjoin=pj)
))
sess = create_session()
@@ -329,7 +329,7 @@ class LazyTest(_fixtures.FixtureTest):
)
mapper(Address, addresses, properties = dict(
- user = relation(mapper(User, users))
+ user = relationship(mapper(User, users))
))
sess = create_session(bind=testing.db)
@@ -349,7 +349,7 @@ class LazyTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_many_to_one(self):
mapper(Address, addresses, properties = dict(
- user = relation(mapper(User, users), lazy=True)
+ user = relationship(mapper(User, users), lazy=True)
))
sess = create_session()
q = sess.query(Address)
@@ -364,7 +364,7 @@ class LazyTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_backrefs_dont_lazyload(self):
mapper(User, users, properties={
- 'addresses':relation(Address, backref='user')
+ 'addresses':relationship(Address, backref='user')
})
mapper(Address, addresses)
sess = create_session()
@@ -407,7 +407,7 @@ class M2OGetTest(_fixtures.FixtureTest):
mapper(User, users)
mapper(Address, addresses, properties={
- 'user':relation(User)
+ 'user':relationship(User)
})
sess = create_session()
@@ -466,7 +466,7 @@ class CorrelatedTest(_base.MappedTest):
stuff_view = sa.select([stuff.c.id]).where(stuff.c.user_id==user_t.c.id).correlate(user_t).order_by(sa.desc(stuff.c.date)).limit(1)
mapper(User, user_t, properties={
- 'stuff':relation(Stuff, primaryjoin=sa.and_(user_t.c.id==stuff.c.user_id, stuff.c.id==(stuff_view.as_scalar())))
+ 'stuff':relationship(Stuff, primaryjoin=sa.and_(user_t.c.id==stuff.c.user_id, stuff.c.id==(stuff_view.as_scalar())))
})
sess = create_session()
diff --git a/test/orm/test_lazytest1.py b/test/orm/test_lazytest1.py
index f76cb3203..3a96f430b 100644
--- a/test/orm/test_lazytest1.py
+++ b/test/orm/test_lazytest1.py
@@ -3,7 +3,7 @@ from sqlalchemy.test import testing
from sqlalchemy import Integer, String, ForeignKey
from sqlalchemy.test.schema import Table
from sqlalchemy.test.schema import Column
-from sqlalchemy.orm import mapper, relation, create_session
+from sqlalchemy.orm import mapper, relationship, create_session
from test.orm import _base
@@ -63,7 +63,7 @@ class LazyTest(_base.MappedTest):
class Information(object):
pass
- class Relation(object):
+ class Relationship(object):
pass
class Data(object):
@@ -72,8 +72,8 @@ class LazyTest(_base.MappedTest):
session = create_session()
mapper(Data, data)
- mapper(Relation, rels, properties={
- 'datas': relation(Data,
+ mapper(Relationship, rels, properties={
+ 'datas': relationship(Data,
primaryjoin=sa.and_(
rels.c.info_pk ==
data.c.info_pk,
@@ -81,7 +81,7 @@ class LazyTest(_base.MappedTest):
data.c.timeval <= rels.c.finish),
foreign_keys=[data.c.info_pk])})
mapper(Information, infos, properties={
- 'rels': relation(Relation)
+ 'rels': relationship(Relationship)
})
info = session.query(Information).get(1)
diff --git a/test/orm/test_manytomany.py b/test/orm/test_manytomany.py
index 9a51cf3db..bb7ca8783 100644
--- a/test/orm/test_manytomany.py
+++ b/test/orm/test_manytomany.py
@@ -4,7 +4,7 @@ from sqlalchemy.test import testing
from sqlalchemy import Integer, String, ForeignKey
from sqlalchemy.test.schema import Table
from sqlalchemy.test.schema import Column
-from sqlalchemy.orm import mapper, relation, create_session
+from sqlalchemy.orm import mapper, relationship, create_session
from test.orm import _base
@@ -70,10 +70,10 @@ class M2MTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_error(self):
mapper(Place, place, properties={
- 'transitions':relation(Transition, secondary=place_input, backref='places')
+ 'transitions':relationship(Transition, secondary=place_input, backref='places')
})
mapper(Transition, transition, properties={
- 'places':relation(Place, secondary=place_input, backref='transitions')
+ 'places':relationship(Place, secondary=place_input, backref='transitions')
})
assert_raises_message(sa.exc.ArgumentError, "Error creating backref",
sa.orm.compile_mappers)
@@ -84,7 +84,7 @@ class M2MTest(_base.MappedTest):
Place.mapper = mapper(Place, place)
- Place.mapper.add_property('places', relation(
+ Place.mapper.add_property('places', relationship(
Place.mapper, secondary=place_place, primaryjoin=place.c.place_id==place_place.c.pl1_id,
secondaryjoin=place.c.place_id==place_place.c.pl2_id,
order_by=place_place.c.pl2_id,
@@ -130,16 +130,16 @@ class M2MTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_double(self):
- """test that a mapper can have two eager relations to the same table, via
+ """test that a mapper can have two eager relationships to the same table, via
two different association tables. aliases are required."""
Place.mapper = mapper(Place, place, properties = {
- 'thingies':relation(mapper(PlaceThingy, place_thingy), lazy=False)
+ 'thingies':relationship(mapper(PlaceThingy, place_thingy), lazy=False)
})
Transition.mapper = mapper(Transition, transition, properties = dict(
- inputs = relation(Place.mapper, place_output, lazy=False),
- outputs = relation(Place.mapper, place_input, lazy=False),
+ inputs = relationship(Place.mapper, place_output, lazy=False),
+ outputs = relationship(Place.mapper, place_input, lazy=False),
)
)
@@ -164,8 +164,8 @@ class M2MTest(_base.MappedTest):
"""tests a many-to-many backrefs"""
Place.mapper = mapper(Place, place)
Transition.mapper = mapper(Transition, transition, properties = dict(
- inputs = relation(Place.mapper, place_output, lazy=True, backref='inputs'),
- outputs = relation(Place.mapper, place_input, lazy=True, backref='outputs'),
+ inputs = relationship(Place.mapper, place_output, lazy=True, backref='inputs'),
+ outputs = relationship(Place.mapper, place_input, lazy=True, backref='outputs'),
)
)
@@ -220,7 +220,7 @@ class M2MTest2(_base.MappedTest):
mapper(Student, student)
mapper(Course, course, properties={
- 'students': relation(Student, enroll, backref='courses')})
+ 'students': relationship(Student, enroll, backref='courses')})
sess = create_session()
s1 = Student('Student1')
@@ -247,7 +247,7 @@ class M2MTest2(_base.MappedTest):
mapper(Student, student)
mapper(Course, course, properties={
- 'students': relation(Student, enroll, backref='courses')})
+ 'students': relationship(Student, enroll, backref='courses')})
sess = create_session()
s1 = Student("s1")
@@ -263,7 +263,7 @@ class M2MTest2(_base.MappedTest):
mapper(Student, student)
mapper(Course, course, properties = {
- 'students': relation(Student, enroll, lazy=True,
+ 'students': relationship(Student, enroll, lazy=True,
backref='courses')})
sess = create_session()
@@ -314,13 +314,13 @@ class M2MTest3(_base.MappedTest):
mapper(B, b)
mapper(A, a, properties={
- 'tbs': relation(B, primaryjoin=sa.and_(b.c.a1 == a.c.a1,
+ 'tbs': relationship(B, primaryjoin=sa.and_(b.c.a1 == a.c.a1,
b.c.b2 == True),
lazy=False)})
mapper(C, c, properties={
- 'a1s': relation(A, secondary=c2a1, lazy=False),
- 'a2s': relation(A, secondary=c2a2, lazy=False)})
+ 'a1s': relationship(A, secondary=c2a1, lazy=False),
+ 'a2s': relationship(A, secondary=c2a2, lazy=False)})
assert create_session().query(C).with_labels().statement is not None
diff --git a/test/orm/test_mapper.py b/test/orm/test_mapper.py
index 31939a962..09d1387f7 100644
--- a/test/orm/test_mapper.py
+++ b/test/orm/test_mapper.py
@@ -6,8 +6,8 @@ from sqlalchemy.test import testing, pickleable
from sqlalchemy import MetaData, Integer, String, ForeignKey, func, util
from sqlalchemy.test.schema import Table, Column
from sqlalchemy.engine import default
-from sqlalchemy.orm import mapper, relation, backref, create_session, class_mapper, compile_mappers, reconstructor, validates, aliased
-from sqlalchemy.orm import defer, deferred, synonym, attributes, column_property, composite, relation, dynamic_loader, comparable_property,AttributeExtension
+from sqlalchemy.orm import mapper, relationship, backref, create_session, class_mapper, compile_mappers, reconstructor, validates, aliased
+from sqlalchemy.orm import defer, deferred, synonym, attributes, column_property, composite, relationship, dynamic_loader, comparable_property,AttributeExtension
from sqlalchemy.test.testing import eq_, AssertsCompiledSQL
from test.orm import _base, _fixtures
from sqlalchemy.test.assertsql import AllOf, CompiledSQL
@@ -22,7 +22,7 @@ class MapperTest(_fixtures.FixtureTest):
mapper(Address, addresses)
mapper(User, users,
properties={
- 'addresses':relation(Address, backref='email_address')
+ 'addresses':relationship(Address, backref='email_address')
})
assert_raises(sa.exc.ArgumentError, sa.orm.compile_mappers)
@@ -84,14 +84,14 @@ class MapperTest(_fixtures.FixtureTest):
def test_bad_cascade(self):
mapper(Address, addresses)
assert_raises(sa.exc.ArgumentError,
- relation, Address, cascade="fake, all, delete-orphan")
+ relationship, Address, cascade="fake, all, delete-orphan")
@testing.resolve_artifact_names
def test_exceptions_sticky(self):
"""test preservation of mapper compile errors raised during hasattr()."""
mapper(Address, addresses, properties={
- 'user':relation(User)
+ 'user':relationship(User)
})
hasattr(Address.user, 'property')
@@ -128,7 +128,7 @@ class MapperTest(_fixtures.FixtureTest):
assert sa.orm.mapperlib._new_mappers is False
m = mapper(Address, addresses, properties={
- 'user': relation(User, backref="addresses")})
+ 'user': relationship(User, backref="addresses")})
assert m.compiled is False
assert sa.orm.mapperlib._new_mappers is True
@@ -222,21 +222,21 @@ class MapperTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_props(self):
m = mapper(User, users, properties = {
- 'addresses' : relation(mapper(Address, addresses))
+ 'addresses' : relationship(mapper(Address, addresses))
}).compile()
assert User.addresses.property is m.get_property('addresses')
@testing.resolve_artifact_names
def test_compile_on_prop_1(self):
mapper(User, users, properties = {
- 'addresses' : relation(mapper(Address, addresses))
+ 'addresses' : relationship(mapper(Address, addresses))
})
User.addresses.any(Address.email_address=='foo@bar.com')
@testing.resolve_artifact_names
def test_compile_on_prop_2(self):
mapper(User, users, properties = {
- 'addresses' : relation(mapper(Address, addresses))
+ 'addresses' : relationship(mapper(Address, addresses))
})
eq_(str(User.id == 3), str(users.c.id==3))
@@ -264,7 +264,7 @@ class MapperTest(_fixtures.FixtureTest):
mapper(Foo, addresses, inherits=User)
ext_list = [AttributeExtension()]
m.add_property('somename', column_property(users.c.name, extension=ext_list))
- m.add_property('orders', relation(Order, extension=ext_list, backref='user'))
+ m.add_property('orders', relationship(Order, extension=ext_list, backref='user'))
assert len(ext_list) == 1
assert Foo.orders.impl.extensions is User.orders.impl.extensions
@@ -327,7 +327,7 @@ class MapperTest(_fixtures.FixtureTest):
m.add_property('_name', deferred(users.c.name))
m.add_property('name', synonym('_name'))
- m.add_property('addresses', relation(Address))
+ m.add_property('addresses', relationship(Address))
m.add_property('uc_name', sa.orm.comparable_property(UCComparator))
m.add_property('uc_name2', sa.orm.comparable_property(
UCComparator, User.uc_name2))
@@ -398,7 +398,7 @@ class MapperTest(_fixtures.FixtureTest):
# later, backref sets up the prop
mapper(User, users, properties={
- 'addresses':relation(Address, backref='_user')
+ 'addresses':relationship(Address, backref='_user')
})
sess = create_session()
@@ -421,7 +421,7 @@ class MapperTest(_fixtures.FixtureTest):
pass
mapper(Node, t, properties={
- '_children':relation(Node, backref=backref('_parent', remote_side=t.c.id)),
+ '_children':relationship(Node, backref=backref('_parent', remote_side=t.c.id)),
'children':synonym('_children'),
'parent':synonym('_parent')
})
@@ -439,11 +439,11 @@ class MapperTest(_fixtures.FixtureTest):
mapper(Address, addresses)
try:
mapper(User, users, non_primary=True, properties={
- 'addresses':relation(Address)
+ 'addresses':relationship(Address)
}).compile()
assert False
except sa.exc.ArgumentError, e:
- assert "Attempting to assign a new relation 'addresses' to a non-primary mapper on class 'User'" in str(e)
+ assert "Attempting to assign a new relationship 'addresses' to a non-primary mapper on class 'User'" in str(e)
@testing.resolve_artifact_names
def test_illegal_non_primary_2(self):
@@ -478,7 +478,7 @@ class MapperTest(_fixtures.FixtureTest):
include_properties=('id', 'type', 'name'))
e_m = mapper(Employee, inherits=p_m, polymorphic_identity='employee',
properties={
- 'boss': relation(Manager, backref=backref('peon', ), remote_side=t.c.id)
+ 'boss': relationship(Manager, backref=backref('peon', ), remote_side=t.c.id)
},
exclude_properties=('vendor_id',))
@@ -602,10 +602,10 @@ class MapperTest(_fixtures.FixtureTest):
mapper(Item, items)
mapper(Order, orders, properties=dict(
- items=relation(Item, order_items)))
+ items=relationship(Item, order_items)))
mapper(User, users, properties=dict(
- orders=relation(Order)))
+ orders=relationship(Order)))
session = create_session()
l = (session.query(User).
@@ -674,7 +674,7 @@ class MapperTest(_fixtures.FixtureTest):
def test_many_to_many_count(self):
mapper(Keyword, keywords)
mapper(Item, items, properties=dict(
- keywords = relation(Keyword, item_keywords, lazy=True)))
+ keywords = relationship(Keyword, item_keywords, lazy=True)))
session = create_session()
q = (session.query(Item).
@@ -689,7 +689,7 @@ class MapperTest(_fixtures.FixtureTest):
def go():
mapper(User, users,
properties=dict(
- name=relation(mapper(Address, addresses))))
+ name=relationship(mapper(Address, addresses))))
assert_raises(sa.exc.ArgumentError, go)
@@ -700,7 +700,7 @@ class MapperTest(_fixtures.FixtureTest):
mapper(User, users,
exclude_properties=['name'],
properties=dict(
- name=relation(mapper(Address, addresses))))
+ name=relationship(mapper(Address, addresses))))
assert bool(User.name)
@@ -709,7 +709,7 @@ class MapperTest(_fixtures.FixtureTest):
"""The column being named elsewhere also cancels the error,"""
mapper(User, users,
properties=dict(
- name=relation(mapper(Address, addresses)),
+ name=relationship(mapper(Address, addresses)),
foo=users.c.name))
@testing.resolve_artifact_names
@@ -731,7 +731,7 @@ class MapperTest(_fixtures.FixtureTest):
uname = extendedproperty(_get_name, _set_name)
mapper(User, users, properties=dict(
- addresses = relation(mapper(Address, addresses), lazy=True),
+ addresses = relationship(mapper(Address, addresses), lazy=True),
uname = synonym('name'),
adlist = synonym('addresses'),
adname = synonym('addresses')
@@ -810,7 +810,7 @@ class MapperTest(_fixtures.FixtureTest):
mapper(Address, addresses)
mapper(User, users, properties = {
- 'addresses':relation(Address, lazy=True),
+ 'addresses':relationship(Address, lazy=True),
'name':synonym('_name', map_column=True)
})
@@ -1057,7 +1057,7 @@ class MapperTest(_fixtures.FixtureTest):
sa.orm.clear_mappers()
mapper(User, users, properties={
- 'addresses':relation(Address)
+ 'addresses':relationship(Address)
})
assert_raises(sa.orm.exc.UnmappedClassError, sa.orm.compile_mappers)
@@ -1086,7 +1086,7 @@ class OptionsTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_synonym_options(self):
mapper(User, users, properties=dict(
- addresses = relation(mapper(Address, addresses), lazy=True,
+ addresses = relationship(mapper(Address, addresses), lazy=True,
order_by=addresses.c.id),
adlist = synonym('addresses')))
@@ -1103,9 +1103,9 @@ class OptionsTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_eager_options(self):
- """A lazy relation can be upgraded to an eager relation."""
+ """A lazy relationship can be upgraded to an eager relationship."""
mapper(User, users, properties=dict(
- addresses = relation(mapper(Address, addresses),
+ addresses = relationship(mapper(Address, addresses),
order_by=addresses.c.id)))
sess = create_session()
@@ -1121,7 +1121,7 @@ class OptionsTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_eager_options_with_limit(self):
mapper(User, users, properties=dict(
- addresses=relation(mapper(Address, addresses), lazy=True)))
+ addresses=relationship(mapper(Address, addresses), lazy=True)))
sess = create_session()
u = (sess.query(User).
@@ -1143,7 +1143,7 @@ class OptionsTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_lazy_options_with_limit(self):
mapper(User, users, properties=dict(
- addresses = relation(mapper(Address, addresses), lazy=False)))
+ addresses = relationship(mapper(Address, addresses), lazy=False)))
sess = create_session()
u = (sess.query(User).
@@ -1157,9 +1157,9 @@ class OptionsTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_eager_degrade(self):
- """An eager relation automatically degrades to a lazy relation if eager columns are not available"""
+ """An eager relationship automatically degrades to a lazy relationship if eager columns are not available"""
mapper(User, users, properties=dict(
- addresses = relation(mapper(Address, addresses), lazy=False)))
+ addresses = relationship(mapper(Address, addresses), lazy=False)))
sess = create_session()
# first test straight eager load, 1 statement
@@ -1191,18 +1191,18 @@ class OptionsTest(_fixtures.FixtureTest):
mapper(Keyword, keywords)
mapper(Item, items, properties=dict(
- keywords=relation(Keyword, secondary=item_keywords,
+ keywords=relationship(Keyword, secondary=item_keywords,
lazy=False,
order_by=item_keywords.c.keyword_id)))
mapper(Order, orders, properties=dict(
- items=relation(Item, secondary=order_items, lazy=False,
+ items=relationship(Item, secondary=order_items, lazy=False,
order_by=order_items.c.item_id)))
mapper(User, users, properties=dict(
- addresses=relation(Address, lazy=False,
+ addresses=relationship(Address, lazy=False,
order_by=addresses.c.id),
- orders=relation(Order, lazy=False,
+ orders=relationship(Order, lazy=False,
order_by=orders.c.id)))
sess = create_session()
@@ -1225,9 +1225,9 @@ class OptionsTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_lazy_options(self):
- """An eager relation can be upgraded to a lazy relation."""
+ """An eager relationship can be upgraded to a lazy relationship."""
mapper(User, users, properties=dict(
- addresses = relation(mapper(Address, addresses), lazy=False)
+ addresses = relationship(mapper(Address, addresses), lazy=False)
))
sess = create_session()
@@ -1242,10 +1242,10 @@ class OptionsTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_option_propagate(self):
mapper(User, users, properties=dict(
- orders = relation(Order)
+ orders = relationship(Order)
))
mapper(Order, orders, properties=dict(
- items = relation(Item, secondary=order_items)
+ items = relationship(Item, secondary=order_items)
))
mapper(Item, items)
@@ -1270,15 +1270,15 @@ class DeepOptionsTest(_fixtures.FixtureTest):
mapper(Keyword, keywords)
mapper(Item, items, properties=dict(
- keywords=relation(Keyword, item_keywords,
+ keywords=relationship(Keyword, item_keywords,
order_by=item_keywords.c.item_id)))
mapper(Order, orders, properties=dict(
- items=relation(Item, order_items,
+ items=relationship(Item, order_items,
order_by=items.c.id)))
mapper(User, users, order_by=users.c.id, properties=dict(
- orders=relation(Order, order_by=orders.c.id)))
+ orders=relationship(Order, order_by=orders.c.id)))
@testing.resolve_artifact_names
def test_deep_options_1(self):
@@ -1365,7 +1365,7 @@ class ValidatorTest(_fixtures.FixtureTest):
assert '@' in ad.email_address
return ad
- mapper(User, users, properties={'addresses':relation(Address)})
+ mapper(User, users, properties={'addresses':relationship(Address)})
mapper(Address, addresses)
sess = create_session()
u1 = User(name='edward')
@@ -1396,7 +1396,7 @@ class ComparatorFactoryTest(_fixtures.FixtureTest, AssertsCompiledSQL):
(deferred, users.c.name),
(synonym, 'name'),
(composite, DummyComposite, users.c.id, users.c.name),
- (relation, Address),
+ (relationship, Address),
(backref, 'address'),
(comparable_property, ),
(dynamic_loader, Address)
@@ -1429,7 +1429,7 @@ class ComparatorFactoryTest(_fixtures.FixtureTest, AssertsCompiledSQL):
self.assert_compile(aliased(User).name == 'ed', "foobar(users_1.name) = foobar(:foobar_1)", dialect=default.DefaultDialect())
@testing.resolve_artifact_names
- def test_relation(self):
+ def test_relationship(self):
from sqlalchemy.orm.properties import PropertyLoader
class MyFactory(PropertyLoader.Comparator):
@@ -1444,7 +1444,7 @@ class ComparatorFactoryTest(_fixtures.FixtureTest, AssertsCompiledSQL):
mapper(User, users)
mapper(Address, addresses, properties={
- 'user':relation(User, comparator_factory=MyFactory,
+ 'user':relationship(User, comparator_factory=MyFactory,
backref=backref("addresses", comparator_factory=MyFactory2)
)
}
@@ -1726,9 +1726,9 @@ class DeferredTest(_fixtures.FixtureTest):
mapper(Item, items, properties=dict(
description=deferred(items.c.description)))
mapper(Order, orders, properties=dict(
- items=relation(Item, secondary=order_items)))
+ items=relationship(Item, secondary=order_items)))
mapper(User, users, properties=dict(
- orders=relation(Order, order_by=orders.c.id)))
+ orders=relationship(Order, order_by=orders.c.id)))
sess = create_session()
q = sess.query(User).order_by(User.id)
@@ -1784,10 +1784,10 @@ class SecondaryOptionsTest(_base.MappedTest):
class Related(_base.ComparableEntity):
pass
mapper(Base, base, polymorphic_on=base.c.type, properties={
- 'related':relation(Related, uselist=False)
+ 'related':relationship(Related, uselist=False)
})
mapper(Child1, child1, inherits=Base, polymorphic_identity='child1', properties={
- 'child2':relation(Child2, primaryjoin=child1.c.child2id==base.c.id, foreign_keys=child1.c.child2id)
+ 'child2':relationship(Child2, primaryjoin=child1.c.child2id==base.c.id, foreign_keys=child1.c.child2id)
})
mapper(Child2, child2, inherits=Base, polymorphic_identity='child2')
mapper(Related, related)
@@ -1925,7 +1925,7 @@ class DeferredPopulationTest(_base.MappedTest):
class Human(_base.BasicEntity): pass
class Thing(_base.BasicEntity): pass
- mapper(Human, human, properties={"thing": relation(Thing)})
+ mapper(Human, human, properties={"thing": relationship(Thing)})
mapper(Thing, thing, properties={"name": deferred(thing.c.name)})
@classmethod
@@ -2045,7 +2045,7 @@ class CompositeTypesTest(_base.MappedTest):
self.end = end
mapper(Graph, graphs, properties={
- 'edges':relation(Edge)
+ 'edges':relationship(Edge)
})
mapper(Edge, edges, properties={
'start':sa.orm.composite(Point, edges.c.x1, edges.c.y1),
@@ -2269,7 +2269,7 @@ class CompositeTypesTest(_base.MappedTest):
self.end = end
mapper(Graph, graphs, properties={
- 'edges':relation(Edge)
+ 'edges':relationship(Edge)
})
mapper(Edge, edges, properties={
'start':sa.orm.composite(Point, edges.c.x1, edges.c.y1),
@@ -2301,7 +2301,7 @@ class NoLoadTest(_fixtures.FixtureTest):
def test_basic(self):
"""A basic one-to-many lazy load"""
m = mapper(User, users, properties=dict(
- addresses = relation(mapper(Address, addresses), lazy=None)
+ addresses = relationship(mapper(Address, addresses), lazy=None)
))
q = create_session().query(m)
l = [None]
@@ -2318,7 +2318,7 @@ class NoLoadTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_options(self):
m = mapper(User, users, properties=dict(
- addresses = relation(mapper(Address, addresses), lazy=None)
+ addresses = relationship(mapper(Address, addresses), lazy=None)
))
q = create_session().query(m).options(sa.orm.lazyload('addresses'))
l = [None]
@@ -2516,7 +2516,7 @@ class MapperExtensionTest(_fixtures.FixtureTest):
Ext, methods = self.extension()
mapper(Item, items, extension=Ext() , properties={
- 'keywords': relation(Keyword, secondary=item_keywords)})
+ 'keywords': relationship(Keyword, secondary=item_keywords)})
mapper(Keyword, keywords, extension=Ext())
sess = create_session()
@@ -2660,13 +2660,13 @@ class RequirementsTest(_base.MappedTest):
pass
mapper(H1, ht1, properties={
- 'h2s': relation(H2, backref='h1'),
- 'h3s': relation(H3, secondary=ht4, backref='h1s'),
- 'h1s': relation(H1, secondary=ht5, backref='parent_h1'),
- 't6a': relation(H6, backref='h1a',
- primaryjoin=ht1.c.id==ht6.c.ht1a_id),
- 't6b': relation(H6, backref='h1b',
- primaryjoin=ht1.c.id==ht6.c.ht1b_id),
+ 'h2s': relationship(H2, backref='h1'),
+ 'h3s': relationship(H3, secondary=ht4, backref='h1s'),
+ 'h1s': relationship(H1, secondary=ht5, backref='parent_h1'),
+ 't6a': relationship(H6, backref='h1a',
+ primaryjoin=ht1.c.id==ht6.c.ht1a_id),
+ 't6b': relationship(H6, backref='h1b',
+ primaryjoin=ht1.c.id==ht6.c.ht1b_id),
})
mapper(H2, ht2)
mapper(H3, ht3)
@@ -2778,7 +2778,7 @@ class MagicNamesTest(_base.MappedTest):
mapper(Cartographer, cartographers, properties=dict(
query=cartographers.c.quip))
mapper(Map, maps, properties=dict(
- mapper=relation(Cartographer, backref='maps')))
+ mapper=relationship(Cartographer, backref='maps')))
c = Cartographer(name='Lenny', alias='The Dude',
query='Where be dragons?')
diff --git a/test/orm/test_merge.py b/test/orm/test_merge.py
index 8dc849e01..9f8861ad8 100644
--- a/test/orm/test_merge.py
+++ b/test/orm/test_merge.py
@@ -4,7 +4,7 @@ from sqlalchemy import Integer, PickleType, String
import operator
from sqlalchemy.test import testing
from sqlalchemy.util import OrderedSet
-from sqlalchemy.orm import mapper, relation, create_session, PropComparator, \
+from sqlalchemy.orm import mapper, relationship, create_session, PropComparator, \
synonym, comparable_property, sessionmaker, attributes
from sqlalchemy.orm.collections import attribute_mapped_collection
from sqlalchemy.orm.interfaces import MapperOption
@@ -57,7 +57,7 @@ class MergeTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_transient_to_pending_collection(self):
mapper(User, users, properties={
- 'addresses': relation(Address, backref='user',
+ 'addresses': relationship(Address, backref='user',
collection_class=OrderedSet)})
mapper(Address, addresses)
on_load = self.on_load_tracker(User)
@@ -113,7 +113,7 @@ class MergeTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_transient_to_persistent_collection(self):
mapper(User, users, properties={
- 'addresses':relation(Address,
+ 'addresses':relationship(Address,
backref='user',
collection_class=OrderedSet,
order_by=addresses.c.id,
@@ -166,7 +166,7 @@ class MergeTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_detached_to_persistent_collection(self):
mapper(User, users, properties={
- 'addresses':relation(Address,
+ 'addresses':relationship(Address,
backref='user',
order_by=addresses.c.id,
collection_class=OrderedSet)})
@@ -201,10 +201,10 @@ class MergeTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_unsaved_cascade(self):
- """Merge of a transient entity with two child transient entities, with a bidirectional relation."""
+ """Merge of a transient entity with two child transient entities, with a bidirectional relationship."""
mapper(User, users, properties={
- 'addresses':relation(mapper(Address, addresses),
+ 'addresses':relationship(mapper(Address, addresses),
cascade="all", backref="user")
})
on_load = self.on_load_tracker(User)
@@ -305,7 +305,7 @@ class MergeTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_merge_irregular_collection(self):
mapper(User, users, properties={
- 'addresses': relation(
+ 'addresses': relationship(
mapper(Address, addresses),
backref='user',
collection_class=attribute_mapped_collection('email_address')),
@@ -322,7 +322,7 @@ class MergeTest(_fixtures.FixtureTest):
"""Merge of a persistent entity with two child persistent entities."""
mapper(User, users, properties={
- 'addresses':relation(mapper(Address, addresses), backref='user')
+ 'addresses':relationship(mapper(Address, addresses), backref='user')
})
on_load = self.on_load_tracker(User)
self.on_load_tracker(Address, on_load)
@@ -414,12 +414,12 @@ class MergeTest(_fixtures.FixtureTest):
eq_(on_load.called, 21)
@testing.resolve_artifact_names
- def test_no_relation_cascade(self):
- """test that merge doesn't interfere with a relation()
+ def test_no_relationship_cascade(self):
+ """test that merge doesn't interfere with a relationship()
target that specifically doesn't include 'merge' cascade.
"""
mapper(Address, addresses, properties={
- 'user':relation(User, cascade="save-update")
+ 'user':relationship(User, cascade="save-update")
})
mapper(User, users)
sess = create_session()
@@ -452,7 +452,7 @@ class MergeTest(_fixtures.FixtureTest):
def test_one_to_many_cascade(self):
mapper(User, users, properties={
- 'addresses':relation(mapper(Address, addresses))})
+ 'addresses':relationship(mapper(Address, addresses))})
on_load = self.on_load_tracker(User)
self.on_load_tracker(Address, on_load)
@@ -489,7 +489,7 @@ class MergeTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_many_to_one_cascade(self):
mapper(Address, addresses, properties={
- 'user':relation(User)
+ 'user':relationship(User)
})
mapper(User, users)
@@ -525,7 +525,7 @@ class MergeTest(_fixtures.FixtureTest):
def test_many_to_many_cascade(self):
mapper(Order, orders, properties={
- 'items':relation(mapper(Item, items), secondary=order_items)})
+ 'items':relationship(mapper(Item, items), secondary=order_items)})
on_load = self.on_load_tracker(Order)
self.on_load_tracker(Item, on_load)
@@ -570,7 +570,7 @@ class MergeTest(_fixtures.FixtureTest):
def test_one_to_one_cascade(self):
mapper(User, users, properties={
- 'address':relation(mapper(Address, addresses),uselist = False)
+ 'address':relationship(mapper(Address, addresses),uselist = False)
})
on_load = self.on_load_tracker(User)
self.on_load_tracker(Address, on_load)
@@ -602,7 +602,7 @@ class MergeTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_value_to_none(self):
mapper(User, users, properties={
- 'address':relation(mapper(Address, addresses),uselist = False, backref='user')
+ 'address':relationship(mapper(Address, addresses),uselist = False, backref='user')
})
sess = sessionmaker()()
u = User(id=7, name="fred", address=Address(id=1, email_address='foo@bar.com'))
@@ -650,9 +650,9 @@ class MergeTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_no_load_with_backrefs(self):
- """load=False populates relations in both directions without requiring a load"""
+ """load=False populates relationships in both directions without requiring a load"""
mapper(User, users, properties={
- 'addresses':relation(mapper(Address, addresses), backref='user')
+ 'addresses':relationship(mapper(Address, addresses), backref='user')
})
u = User(id=7, name='fred', addresses=[
@@ -694,7 +694,7 @@ class MergeTest(_fixtures.FixtureTest):
"""
mapper(User, users, properties={
- 'addresses':relation(mapper(Address, addresses))
+ 'addresses':relationship(mapper(Address, addresses))
})
sess = create_session()
u = User()
@@ -754,7 +754,7 @@ class MergeTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_no_load_sets_backrefs(self):
mapper(User, users, properties={
- 'addresses':relation(mapper(Address, addresses),backref='user')})
+ 'addresses':relationship(mapper(Address, addresses),backref='user')})
sess = create_session()
u = User()
@@ -790,7 +790,7 @@ class MergeTest(_fixtures.FixtureTest):
"""
mapper(User, users, properties={
- 'addresses':relation(mapper(Address, addresses),
+ 'addresses':relationship(mapper(Address, addresses),
backref='user', cascade="all, delete-orphan")})
sess = create_session()
u = User()
@@ -878,7 +878,7 @@ class MergeTest(_fixtures.FixtureTest):
s = create_session(autoflush=True)
mapper(User, users, properties={
- 'addresses':relation(mapper(Address, addresses),backref='user')})
+ 'addresses':relationship(mapper(Address, addresses),backref='user')})
a1 = Address(user=s.merge(User(id=1, name='ed')), email_address='x')
before_id = id(a1.user)
@@ -894,7 +894,7 @@ class MergeTest(_fixtures.FixtureTest):
def test_cascades_dont_autoflush(self):
sess = create_session(autoflush=True)
m = mapper(User, users, properties={
- 'addresses':relation(mapper(Address, addresses),backref='user')})
+ 'addresses':relationship(mapper(Address, addresses),backref='user')})
user = User(id=8, name='fred', addresses=[Address(email_address='user')])
merged_user = sess.merge(user)
assert merged_user in sess.new
@@ -904,7 +904,7 @@ class MergeTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_cascades_dont_autoflush_2(self):
mapper(User, users, properties={
- 'addresses':relation(Address,
+ 'addresses':relationship(Address,
backref='user',
cascade="all, delete-orphan")
})
diff --git a/test/orm/test_naturalpks.py b/test/orm/test_naturalpks.py
index 7c7e51b73..806558a2b 100644
--- a/test/orm/test_naturalpks.py
+++ b/test/orm/test_naturalpks.py
@@ -7,7 +7,7 @@ import sqlalchemy as sa
from sqlalchemy.test import testing
from sqlalchemy import Integer, String, ForeignKey, Unicode
from sqlalchemy.test.schema import Table, Column
-from sqlalchemy.orm import mapper, relation, create_session
+from sqlalchemy.orm import mapper, relationship, create_session
from sqlalchemy.test.testing import eq_
from test.orm import _base
@@ -124,7 +124,7 @@ class NaturalPKTest(_base.MappedTest):
@testing.resolve_artifact_names
def _test_onetomany(self, passive_updates):
mapper(User, users, properties={
- 'addresses':relation(Address, passive_updates=passive_updates)
+ 'addresses':relationship(Address, passive_updates=passive_updates)
})
mapper(Address, addresses)
@@ -177,7 +177,7 @@ class NaturalPKTest(_base.MappedTest):
def _test_manytoone(self, passive_updates):
mapper(User, users)
mapper(Address, addresses, properties={
- 'user':relation(User, passive_updates=passive_updates)
+ 'user':relationship(User, passive_updates=passive_updates)
})
sess = create_session()
@@ -219,7 +219,7 @@ class NaturalPKTest(_base.MappedTest):
@testing.resolve_artifact_names
def _test_onetoone(self, passive_updates):
mapper(User, users, properties={
- "address":relation(Address, passive_updates=passive_updates, uselist=False)
+ "address":relationship(Address, passive_updates=passive_updates, uselist=False)
})
mapper(Address, addresses)
@@ -262,7 +262,7 @@ class NaturalPKTest(_base.MappedTest):
def _test_bidirectional(self, passive_updates):
mapper(User, users)
mapper(Address, addresses, properties={
- 'user':relation(User, passive_updates=passive_updates,
+ 'user':relationship(User, passive_updates=passive_updates,
backref='addresses')})
sess = create_session()
@@ -318,7 +318,7 @@ class NaturalPKTest(_base.MappedTest):
@testing.resolve_artifact_names
def _test_manytomany(self, passive_updates):
mapper(User, users, properties={
- 'items':relation(Item, secondary=users_to_items, backref='users',
+ 'items':relationship(Item, secondary=users_to_items, backref='users',
passive_updates=passive_updates)})
mapper(Item, items)
@@ -445,7 +445,7 @@ class SelfRefTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_onetomany(self):
mapper(Node, nodes, properties={
- 'children': relation(Node,
+ 'children': relationship(Node,
backref=sa.orm.backref('parentnode',
remote_side=nodes.c.name,
passive_updates=False),
@@ -508,7 +508,7 @@ class NonPKCascadeTest(_base.MappedTest):
@testing.resolve_artifact_names
def _test_onetomany(self, passive_updates):
mapper(User, users, properties={
- 'addresses':relation(Address, passive_updates=passive_updates)})
+ 'addresses':relationship(Address, passive_updates=passive_updates)})
mapper(Address, addresses)
sess = create_session()
@@ -613,7 +613,7 @@ class CascadeToFKPKTest(_base.MappedTest, testing.AssertsCompiledSQL):
"""
mapper(User, users, properties={
- 'addresses':relation(Address, passive_updates=passive_updates)})
+ 'addresses':relationship(Address, passive_updates=passive_updates)})
mapper(Address, addresses)
sess = create_session()
@@ -631,7 +631,7 @@ class CascadeToFKPKTest(_base.MappedTest, testing.AssertsCompiledSQL):
def test_rowswitch_doesntfire(self):
mapper(User, users)
mapper(Address, addresses, properties={
- 'user':relation(User, passive_updates=True)
+ 'user':relationship(User, passive_updates=True)
})
sess = create_session()
@@ -673,7 +673,7 @@ class CascadeToFKPKTest(_base.MappedTest, testing.AssertsCompiledSQL):
"""
mapper(User, users, properties={
- 'addresses':relation(Address, passive_updates=passive_updates)})
+ 'addresses':relationship(Address, passive_updates=passive_updates)})
mapper(Address, addresses)
sess = create_session()
@@ -756,7 +756,7 @@ class JoinedInheritanceTest(_base.MappedTest):
mapper(Person, person, polymorphic_on=person.c.type,
polymorphic_identity='person', passive_updates=passive_updates)
mapper(Engineer, engineer, inherits=Person, polymorphic_identity='engineer', properties={
- 'boss':relation(Manager,
+ 'boss':relationship(Manager,
primaryjoin=manager.c.name==engineer.c.boss_name,
passive_updates=passive_updates
)
@@ -777,7 +777,7 @@ class JoinedInheritanceTest(_base.MappedTest):
mapper(Person, person, polymorphic_on=person.c.type,
polymorphic_identity='person', passive_updates=passive_updates)
mapper(Engineer, engineer, inherits=Person, polymorphic_identity='engineer', properties={
- 'boss':relation(Manager,
+ 'boss':relationship(Manager,
primaryjoin=manager.c.name==engineer.c.boss_name,
passive_updates=passive_updates
)
diff --git a/test/orm/test_onetoone.py b/test/orm/test_onetoone.py
index 6880f1f74..4e3cade9b 100644
--- a/test/orm/test_onetoone.py
+++ b/test/orm/test_onetoone.py
@@ -2,7 +2,7 @@ import sqlalchemy as sa
from sqlalchemy.test import testing
from sqlalchemy import Integer, String, ForeignKey
from sqlalchemy.test.schema import Table, Column
-from sqlalchemy.orm import mapper, relation, create_session
+from sqlalchemy.orm import mapper, relationship, create_session
from test.orm import _base
@@ -36,7 +36,7 @@ class O2OTest(_base.MappedTest):
mapper(Jack, jack,
order_by=[jack.c.number],
properties=dict(
- port=relation(Port, backref='jack',
+ port=relationship(Port, backref='jack',
uselist=False,
)),
)
diff --git a/test/orm/test_pickled.py b/test/orm/test_pickled.py
index d801ad029..abe4c91a2 100644
--- a/test/orm/test_pickled.py
+++ b/test/orm/test_pickled.py
@@ -5,7 +5,7 @@ from sqlalchemy.test import testing
from sqlalchemy.test.testing import assert_raises_message
from sqlalchemy import Integer, String, ForeignKey, exc
from sqlalchemy.test.schema import Table, Column
-from sqlalchemy.orm import mapper, relation, create_session, \
+from sqlalchemy.orm import mapper, relationship, create_session, \
sessionmaker, attributes, interfaces,\
clear_mappers, exc as orm_exc,\
compile_mappers
@@ -21,7 +21,7 @@ class PickleTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_transient(self):
mapper(User, users, properties={
- 'addresses':relation(Address, backref="user")
+ 'addresses':relationship(Address, backref="user")
})
mapper(Address, addresses)
@@ -70,11 +70,11 @@ class PickleTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_serialize_path(self):
umapper = mapper(User, users, properties={
- 'addresses':relation(Address, backref="user")
+ 'addresses':relationship(Address, backref="user")
})
amapper = mapper(Address, addresses)
- # this is a "relation" path with mapper, key, mapper, key
+ # this is a "relationship" path with mapper, key, mapper, key
p1 = (umapper, 'addresses', amapper, 'email_address')
eq_(
interfaces.deserialize_path(interfaces.serialize_path(p1)),
@@ -100,7 +100,7 @@ class PickleTest(_fixtures.FixtureTest):
def test_class_deferred_cols(self):
mapper(User, users, properties={
'name':sa.orm.deferred(users.c.name),
- 'addresses':relation(Address, backref="user")
+ 'addresses':relationship(Address, backref="user")
})
mapper(Address, addresses, properties={
'email_address':sa.orm.deferred(addresses.c.email_address)
@@ -130,7 +130,7 @@ class PickleTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_instance_deferred_cols(self):
mapper(User, users, properties={
- 'addresses':relation(Address, backref="user")
+ 'addresses':relationship(Address, backref="user")
})
mapper(Address, addresses)
@@ -175,7 +175,7 @@ class PickleTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_pickle_protocols(self):
mapper(User, users, properties={
- 'addresses':relation(Address, backref="user")
+ 'addresses':relationship(Address, backref="user")
})
mapper(Address, addresses)
@@ -194,7 +194,7 @@ class PickleTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_options_with_descriptors(self):
mapper(User, users, properties={
- 'addresses':relation(Address, backref="user")
+ 'addresses':relationship(Address, backref="user")
})
mapper(Address, addresses)
sess = create_session()
@@ -287,7 +287,7 @@ class UnpickleSA05Test(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_one(self):
mapper(User, users, properties={
- 'addresses':relation(Address, backref="user")
+ 'addresses':relationship(Address, backref="user")
})
mapper(Address, addresses)
data = \
@@ -300,7 +300,7 @@ class UnpickleSA05Test(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_two(self):
mapper(User, users, properties={
- 'addresses':relation(Address, backref="user")
+ 'addresses':relationship(Address, backref="user")
})
mapper(Address, addresses)
data = \
diff --git a/test/orm/test_query.py b/test/orm/test_query.py
index a2212851d..6de4a31e4 100644
--- a/test/orm/test_query.py
+++ b/test/orm/test_query.py
@@ -32,24 +32,24 @@ class QueryTest(_fixtures.FixtureTest):
@classmethod
def setup_mappers(cls):
mapper(User, users, properties={
- 'addresses':relation(Address, backref='user', order_by=addresses.c.id),
- 'orders':relation(Order, backref='user', order_by=orders.c.id), # o2m, m2o
+ 'addresses':relationship(Address, backref='user', order_by=addresses.c.id),
+ 'orders':relationship(Order, backref='user', order_by=orders.c.id), # o2m, m2o
})
mapper(Address, addresses, properties={
- 'dingaling':relation(Dingaling, uselist=False, backref="address") #o2o
+ 'dingaling':relationship(Dingaling, uselist=False, backref="address") #o2o
})
mapper(Dingaling, dingalings)
mapper(Order, orders, properties={
- 'items':relation(Item, secondary=order_items, order_by=items.c.id), #m2m
- 'address':relation(Address), # m2o
+ 'items':relationship(Item, secondary=order_items, order_by=items.c.id), #m2m
+ 'address':relationship(Address), # m2o
})
mapper(Item, items, properties={
- 'keywords':relation(Keyword, secondary=item_keywords) #m2m
+ 'keywords':relationship(Keyword, secondary=item_keywords) #m2m
})
mapper(Keyword, keywords)
mapper(Node, nodes, properties={
- 'children':relation(Node,
+ 'children':relationship(Node,
backref=backref('parent', remote_side=[nodes.c.id])
)
})
@@ -400,7 +400,7 @@ class OperatorTest(QueryTest, AssertsCompiledSQL):
self._test(None == Address.user, "addresses.user_id IS NULL")
self._test(~(None == Address.user), "addresses.user_id IS NOT NULL")
- def test_relation(self):
+ def test_relationship(self):
self._test(User.addresses.any(Address.id==17),
"EXISTS (SELECT 1 "
"FROM addresses "
@@ -418,7 +418,7 @@ class OperatorTest(QueryTest, AssertsCompiledSQL):
self._test(Address.user != None, "addresses.user_id IS NOT NULL")
- def test_selfref_relation(self):
+ def test_selfref_relationship(self):
nalias = aliased(Node)
# auto self-referential aliasing
@@ -497,7 +497,7 @@ class OperatorTest(QueryTest, AssertsCompiledSQL):
self._test(User.id.in_(['a', 'b']),
"users.id IN (:id_1, :id_2)")
- def test_in_on_relation_not_supported(self):
+ def test_in_on_relationship_not_supported(self):
assert_raises(NotImplementedError, Address.user.in_, [User(id=5)])
def test_neg(self):
@@ -1319,7 +1319,7 @@ class InheritedJoinTest(_base.MappedTest, AssertsCompiledSQL):
pass
mapper(Company, companies, properties={
- 'employees':relation(Person, order_by=people.c.person_id)
+ 'employees':relationship(Person, order_by=people.c.person_id)
})
mapper(Machine, machines)
@@ -1327,10 +1327,10 @@ class InheritedJoinTest(_base.MappedTest, AssertsCompiledSQL):
mapper(Person, people,
polymorphic_on=people.c.type, polymorphic_identity='person', order_by=people.c.person_id,
properties={
- 'paperwork':relation(Paperwork, order_by=paperwork.c.paperwork_id)
+ 'paperwork':relationship(Paperwork, order_by=paperwork.c.paperwork_id)
})
mapper(Engineer, engineers, inherits=Person, polymorphic_identity='engineer', properties={
- 'machines':relation(Machine, order_by=machines.c.machine_id)
+ 'machines':relationship(Machine, order_by=machines.c.machine_id)
})
mapper(Manager, managers,
inherits=Person, polymorphic_identity='manager')
@@ -2167,8 +2167,8 @@ class MultiplePathTest(_base.MappedTest, AssertsCompiledSQL):
class T2(object):pass
mapper(T1, t1, properties={
- 't2s_1':relation(T2, secondary=t1t2_1),
- 't2s_2':relation(T2, secondary=t1t2_2),
+ 't2s_1':relationship(T2, secondary=t1t2_1),
+ 't2s_2':relationship(T2, secondary=t1t2_2),
})
mapper(T2, t2)
@@ -2188,18 +2188,18 @@ class SynonymTest(QueryTest):
def setup_mappers(cls):
mapper(User, users, properties={
'name_syn':synonym('name'),
- 'addresses':relation(Address),
- 'orders':relation(Order, backref='user'), # o2m, m2o
+ 'addresses':relationship(Address),
+ 'orders':relationship(Order, backref='user'), # o2m, m2o
'orders_syn':synonym('orders')
})
mapper(Address, addresses)
mapper(Order, orders, properties={
- 'items':relation(Item, secondary=order_items), #m2m
- 'address':relation(Address), # m2o
+ 'items':relationship(Item, secondary=order_items), #m2m
+ 'address':relationship(Address), # m2o
'items_syn':synonym('items')
})
mapper(Item, items, properties={
- 'keywords':relation(Keyword, secondary=item_keywords) #m2m
+ 'keywords':relationship(Keyword, secondary=item_keywords) #m2m
})
mapper(Keyword, keywords)
@@ -2851,7 +2851,7 @@ class ImmediateTest(_fixtures.FixtureTest):
mapper(Address, addresses)
mapper(User, users, properties=dict(
- addresses=relation(Address)))
+ addresses=relationship(Address)))
@testing.resolve_artifact_names
def test_one(self):
@@ -2945,7 +2945,7 @@ class SelectFromTest(QueryTest):
def test_replace_with_select(self):
mapper(User, users, properties = {
- 'addresses':relation(Address)
+ 'addresses':relationship(Address)
})
mapper(Address, addresses)
@@ -2996,7 +2996,7 @@ class SelectFromTest(QueryTest):
def test_join(self):
mapper(User, users, properties = {
- 'addresses':relation(Address)
+ 'addresses':relationship(Address)
})
mapper(Address, addresses)
@@ -3025,13 +3025,13 @@ class SelectFromTest(QueryTest):
def test_more_joins(self):
mapper(User, users, properties={
- 'orders':relation(Order, backref='user'), # o2m, m2o
+ 'orders':relationship(Order, backref='user'), # o2m, m2o
})
mapper(Order, orders, properties={
- 'items':relation(Item, secondary=order_items, order_by=items.c.id), #m2m
+ 'items':relationship(Item, secondary=order_items, order_by=items.c.id), #m2m
})
mapper(Item, items, properties={
- 'keywords':relation(Keyword, secondary=item_keywords, order_by=keywords.c.id) #m2m
+ 'keywords':relationship(Keyword, secondary=item_keywords, order_by=keywords.c.id) #m2m
})
mapper(Keyword, keywords)
@@ -3080,7 +3080,7 @@ class SelectFromTest(QueryTest):
def test_replace_with_eager(self):
mapper(User, users, properties = {
- 'addresses':relation(Address, order_by=addresses.c.id)
+ 'addresses':relationship(Address, order_by=addresses.c.id)
})
mapper(Address, addresses)
@@ -3115,13 +3115,13 @@ class CustomJoinTest(QueryTest):
"""test aliasing of joins with a custom join condition"""
mapper(Address, addresses)
mapper(Order, orders, properties={
- 'items':relation(Item, secondary=order_items, lazy=True, order_by=items.c.id),
+ 'items':relationship(Item, secondary=order_items, lazy=True, order_by=items.c.id),
})
mapper(Item, items)
mapper(User, users, properties = dict(
- addresses = relation(Address, lazy=True),
- open_orders = relation(Order, primaryjoin = and_(orders.c.isopen == 1, users.c.id==orders.c.user_id), lazy=True),
- closed_orders = relation(Order, primaryjoin = and_(orders.c.isopen == 0, users.c.id==orders.c.user_id), lazy=True)
+ addresses = relationship(Address, lazy=True),
+ open_orders = relationship(Order, primaryjoin = and_(orders.c.isopen == 1, users.c.id==orders.c.user_id), lazy=True),
+ closed_orders = relationship(Order, primaryjoin = and_(orders.c.isopen == 0, users.c.id==orders.c.user_id), lazy=True)
))
q = create_session().query(User)
@@ -3149,7 +3149,7 @@ class SelfReferentialTest(_base.MappedTest):
self.children.append(node)
mapper(Node, nodes, properties={
- 'children':relation(Node, lazy=True, join_depth=3,
+ 'children':relationship(Node, lazy=True, join_depth=3,
backref=backref('parent', remote_side=[nodes.c.id])
)
})
@@ -3332,7 +3332,7 @@ class SelfReferentialM2MTest(_base.MappedTest):
pass
mapper(Node, nodes, properties={
- 'children':relation(Node, lazy=True, secondary=node_to_nodes,
+ 'children':relationship(Node, lazy=True, secondary=node_to_nodes,
primaryjoin=nodes.c.id==node_to_nodes.c.left_node_id,
secondaryjoin=nodes.c.id==node_to_nodes.c.right_node_id,
)
@@ -3398,7 +3398,7 @@ class ExternalColumnsTest(QueryTest):
})
mapper(Address, addresses, properties={
- 'user':relation(User)
+ 'user':relationship(User)
})
sess = create_session()
@@ -3485,13 +3485,13 @@ class ExternalColumnsTest(QueryTest):
# therefore the long standing practice of eager adapters being "chained" has been removed
# since its unnecessary and breaks this exact condition.
mapper(User, users, properties={
- 'addresses':relation(Address, backref='user', order_by=addresses.c.id),
+ 'addresses':relationship(Address, backref='user', order_by=addresses.c.id),
'concat': column_property((users.c.id * 2)),
'count': column_property(select([func.count(addresses.c.id)], users.c.id==addresses.c.user_id).correlate(users))
})
mapper(Address, addresses)
mapper(Order, orders, properties={
- 'address':relation(Address), # m2o
+ 'address':relationship(Address), # m2o
})
sess = create_session()
@@ -3534,8 +3534,8 @@ class TestOverlyEagerEquivalentCols(_base.MappedTest):
pass
mapper(Base, base, properties={
- 'sub1':relation(Sub1),
- 'sub2':relation(Sub2)
+ 'sub1':relationship(Sub1),
+ 'sub2':relationship(Sub2)
})
mapper(Sub1, sub1)
@@ -3609,7 +3609,7 @@ class UpdateDeleteTest(_base.MappedTest):
def setup_mappers(cls):
mapper(User, users)
mapper(Document, documents, properties={
- 'user': relation(User, lazy=False, backref=backref('documents', lazy=True))
+ 'user': relationship(User, lazy=False, backref=backref('documents', lazy=True))
})
@testing.resolve_artifact_names
@@ -3820,7 +3820,7 @@ class UpdateDeleteTest(_base.MappedTest):
eq_(rowcount, 3)
@testing.resolve_artifact_names
- def test_update_with_eager_relations(self):
+ def test_update_with_eager_relationships(self):
self.insert_documents()
sess = create_session(bind=testing.db, autocommit=False)
@@ -3842,7 +3842,7 @@ class UpdateDeleteTest(_base.MappedTest):
eq_(sess.query(User.age).order_by(User.id).all(), zip([25,37,29,27]))
@testing.resolve_artifact_names
- def test_delete_with_eager_relations(self):
+ def test_delete_with_eager_relationships(self):
self.insert_documents()
sess = create_session(bind=testing.db, autocommit=False)
diff --git a/test/orm/test_relationships.py b/test/orm/test_relationships.py
index 1d2869291..116bc1077 100644
--- a/test/orm/test_relationships.py
+++ b/test/orm/test_relationships.py
@@ -4,12 +4,13 @@ import sqlalchemy as sa
from sqlalchemy.test import testing
from sqlalchemy import Integer, String, ForeignKey, MetaData, and_
from sqlalchemy.test.schema import Table, Column
-from sqlalchemy.orm import mapper, relation, backref, create_session, compile_mappers, clear_mappers, sessionmaker
+from sqlalchemy.orm import mapper, relationship, relation, \
+ backref, create_session, compile_mappers, clear_mappers, sessionmaker
from sqlalchemy.test.testing import eq_, startswith_
from test.orm import _base, _fixtures
-class RelationTest(_base.MappedTest):
+class RelationshipTest(_base.MappedTest):
"""An extended topological sort test
This is essentially an extension of the "dependency.py" topological sort
@@ -61,12 +62,12 @@ class RelationTest(_base.MappedTest):
@testing.resolve_artifact_names
def setup_mappers(cls):
mapper(A, tbl_a, properties=dict(
- c_rows=relation(C, cascade="all, delete-orphan", backref="a_row")))
+ c_rows=relationship(C, cascade="all, delete-orphan", backref="a_row")))
mapper(B, tbl_b)
mapper(C, tbl_c, properties=dict(
- d_rows=relation(D, cascade="all, delete-orphan", backref="c_row")))
+ d_rows=relationship(D, cascade="all, delete-orphan", backref="c_row")))
mapper(D, tbl_d, properties=dict(
- b_row=relation(B)))
+ b_row=relationship(B)))
@classmethod
@testing.resolve_artifact_names
@@ -100,8 +101,8 @@ class RelationTest(_base.MappedTest):
session.flush()
-class RelationTest2(_base.MappedTest):
- """The ultimate relation() test:
+class RelationshipTest2(_base.MappedTest):
+ """The ultimate relationship() test:
company employee
---------- ----------
@@ -162,8 +163,8 @@ class RelationTest2(_base.MappedTest):
def test_explicit(self):
mapper(Company, company_t)
mapper(Employee, employee_t, properties= {
- 'company':relation(Company, primaryjoin=employee_t.c.company_id==company_t.c.company_id, backref='employees'),
- 'reports_to':relation(Employee, primaryjoin=
+ 'company':relationship(Company, primaryjoin=employee_t.c.company_id==company_t.c.company_id, backref='employees'),
+ 'reports_to':relationship(Employee, primaryjoin=
sa.and_(
employee_t.c.emp_id==employee_t.c.reports_to_id,
employee_t.c.company_id==employee_t.c.company_id
@@ -179,8 +180,8 @@ class RelationTest2(_base.MappedTest):
def test_implicit(self):
mapper(Company, company_t)
mapper(Employee, employee_t, properties= {
- 'company':relation(Company, backref='employees'),
- 'reports_to':relation(Employee,
+ 'company':relationship(Company, backref='employees'),
+ 'reports_to':relationship(Employee,
remote_side=[employee_t.c.emp_id, employee_t.c.company_id],
foreign_keys=[employee_t.c.reports_to_id],
backref=backref('employees', foreign_keys=None)
@@ -193,8 +194,8 @@ class RelationTest2(_base.MappedTest):
def test_very_implicit(self):
mapper(Company, company_t)
mapper(Employee, employee_t, properties= {
- 'company':relation(Company, backref='employees'),
- 'reports_to':relation(Employee,
+ 'company':relationship(Company, backref='employees'),
+ 'reports_to':relationship(Employee,
remote_side=[employee_t.c.emp_id, employee_t.c.company_id],
backref='employees'
)
@@ -206,8 +207,8 @@ class RelationTest2(_base.MappedTest):
def test_very_explicit(self):
mapper(Company, company_t)
mapper(Employee, employee_t, properties= {
- 'company':relation(Company, backref='employees'),
- 'reports_to':relation(Employee,
+ 'company':relationship(Company, backref='employees'),
+ 'reports_to':relationship(Employee,
_local_remote_pairs = [
(employee_t.c.reports_to_id, employee_t.c.emp_id),
(employee_t.c.company_id, employee_t.c.company_id)
@@ -246,7 +247,7 @@ class RelationTest2(_base.MappedTest):
assert sess.query(Employee).get([c1.company_id, 3]).reports_to.name == 'emp1'
assert sess.query(Employee).get([c2.company_id, 3]).reports_to.name == 'emp5'
-class RelationTest3(_base.MappedTest):
+class RelationshipTest3(_base.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table("jobs", metadata,
@@ -322,12 +323,12 @@ class RelationTest3(_base.MappedTest):
mapper(Job, jobs)
mapper(PageVersion, pageversions)
mapper(Page, pages, properties={
- 'job': relation(
+ 'job': relationship(
Job,
backref=backref('pages',
cascade="all, delete-orphan",
order_by=pages.c.pagename)),
- 'currentversion': relation(
+ 'currentversion': relationship(
PageVersion,
uselist=False,
primaryjoin=sa.and_(
@@ -335,7 +336,7 @@ class RelationTest3(_base.MappedTest):
pages.c.pagename==pageversions.c.pagename,
pages.c.current_version==pageversions.c.version),
post_update=True),
- 'versions': relation(
+ 'versions': relationship(
PageVersion,
cascade="all, delete-orphan",
primaryjoin=sa.and_(pages.c.jobno==pageversions.c.jobno,
@@ -344,7 +345,7 @@ class RelationTest3(_base.MappedTest):
backref=backref('page',lazy=False)
)})
mapper(PageComment, pagecomments, properties={
- 'page': relation(
+ 'page': relationship(
Page,
primaryjoin=sa.and_(pages.c.jobno==pagecomments.c.jobno,
pages.c.pagename==pagecomments.c.pagename),
@@ -388,7 +389,7 @@ class RelationTest3(_base.MappedTest):
s.delete(j)
s.flush()
-class RelationTest4(_base.MappedTest):
+class RelationshipTest4(_base.MappedTest):
"""Syncrules on foreign keys that are also primary"""
@classmethod
@@ -415,7 +416,7 @@ class RelationTest4(_base.MappedTest):
"""test that active history is enabled on a one-to-many/one that has use_get==True"""
mapper(A, tableA, properties={
- 'b':relation(B, cascade="all,delete-orphan", uselist=False)})
+ 'b':relationship(B, cascade="all,delete-orphan", uselist=False)})
mapper(B, tableB)
compile_mappers()
@@ -435,7 +436,7 @@ class RelationTest4(_base.MappedTest):
def test_no_delete_PK_AtoB(self):
"""A cant be deleted without B because B would have no PK value."""
mapper(A, tableA, properties={
- 'bs':relation(B, cascade="save-update")})
+ 'bs':relationship(B, cascade="save-update")})
mapper(B, tableB)
a1 = A()
@@ -456,7 +457,7 @@ class RelationTest4(_base.MappedTest):
@testing.resolve_artifact_names
def test_no_delete_PK_BtoA(self):
mapper(B, tableB, properties={
- 'a':relation(A, cascade="save-update")})
+ 'a':relationship(A, cascade="save-update")})
mapper(A, tableA)
b1 = B()
@@ -487,7 +488,7 @@ class RelationTest4(_base.MappedTest):
class C(_base.Entity):
pass
mapper(C, tableC, properties={
- 'a':relation(A, cascade="save-update")
+ 'a':relationship(A, cascade="save-update")
})
mapper(A, tableA)
@@ -507,7 +508,7 @@ class RelationTest4(_base.MappedTest):
#"save-update, delete-orphan",
"save-update, delete, delete-orphan"):
mapper(B, tableB, properties={
- 'a':relation(A, cascade=cascade, single_parent=True)
+ 'a':relationship(A, cascade=cascade, single_parent=True)
})
mapper(A, tableA)
@@ -531,7 +532,7 @@ class RelationTest4(_base.MappedTest):
#"save-update, delete-orphan",
"save-update, delete, delete-orphan"):
mapper(A, tableA, properties={
- 'bs':relation(B, cascade=cascade)
+ 'bs':relationship(B, cascade=cascade)
})
mapper(B, tableB)
@@ -552,7 +553,7 @@ class RelationTest4(_base.MappedTest):
@testing.resolve_artifact_names
def test_delete_manual_AtoB(self):
mapper(A, tableA, properties={
- 'bs':relation(B, cascade="none")})
+ 'bs':relationship(B, cascade="none")})
mapper(B, tableB)
a1 = A()
@@ -573,7 +574,7 @@ class RelationTest4(_base.MappedTest):
@testing.resolve_artifact_names
def test_delete_manual_BtoA(self):
mapper(B, tableB, properties={
- 'a':relation(A, cascade="none")})
+ 'a':relationship(A, cascade="none")})
mapper(A, tableA)
b1 = B()
@@ -589,8 +590,8 @@ class RelationTest4(_base.MappedTest):
assert a1 not in sess
assert b1 not in sess
-class RelationToUniqueTest(_base.MappedTest):
- """test a relation based on a primary join against a unique non-pk column"""
+class RelationshipToUniqueTest(_base.MappedTest):
+ """test a relationship based on a primary join against a unique non-pk column"""
@classmethod
def define_tables(cls, metadata):
@@ -614,7 +615,7 @@ class RelationToUniqueTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_switch_parent(self):
mapper(A, table_a)
- mapper(B, table_b, properties={"a": relation(A, backref="bs")})
+ mapper(B, table_b, properties={"a": relationship(A, backref="bs")})
session = create_session()
a1, a2 = A(ident="uuid1"), A(ident="uuid2")
@@ -631,7 +632,7 @@ class RelationToUniqueTest(_base.MappedTest):
session.delete(a1)
session.flush()
-class RelationTest5(_base.MappedTest):
+class RelationshipTest5(_base.MappedTest):
"""Test a map to a select that relates to a map to the table."""
@classmethod
@@ -664,7 +665,7 @@ class RelationTest5(_base.MappedTest):
container_select,
order_by=sa.asc(container_select.c.type),
properties=dict(
- lineItems=relation(LineItem,
+ lineItems=relationship(LineItem,
lazy=True,
cascade='all, delete-orphan',
order_by=sa.asc(items.c.id),
@@ -696,8 +697,8 @@ class RelationTest5(_base.MappedTest):
for old, new in zip(con.lineItems, newcon.lineItems):
eq_(old.id, new.id)
-class RelationTest6(_base.MappedTest):
- """test a relation with a non-column entity in the primary join,
+class RelationshipTest6(_base.MappedTest):
+ """test a relationship with a non-column entity in the primary join,
is not viewonly, and also has the non-column's clause mentioned in the
foreign keys list.
@@ -723,7 +724,7 @@ class RelationTest6(_base.MappedTest):
pass
mapper(Tag, tags, properties={
- 'foo':relation(TagInstance,
+ 'foo':relationship(TagInstance,
primaryjoin=sa.and_(tag_foo.c.data=='iplc_case',
tag_foo.c.tagid==tags.c.id),
foreign_keys=[tag_foo.c.tagid, tag_foo.c.data],
@@ -740,7 +741,7 @@ class RelationTest6(_base.MappedTest):
sess.flush()
sess.expunge_all()
- # relation works
+ # relationship works
eq_(sess.query(Tag).all(), [Tag(data='some tag', foo=[TagInstance(data='iplc_case')])])
# both TagInstances were persisted
@@ -774,7 +775,7 @@ class BackrefPropagatesForwardsArgs(_base.MappedTest):
def test_backref(self):
mapper(User, users, properties={
- 'addresses':relation(Address,
+ 'addresses':relationship(Address,
primaryjoin=addresses.c.user_id==users.c.id,
foreign_keys=addresses.c.user_id,
backref='user')
@@ -827,7 +828,7 @@ class AmbiguousJoinInterpretedAsSelfRef(_base.MappedTest):
mapper(Subscriber, subscriber_and_address, properties={
'id':[subscriber.c.id, address.c.subscriber_id],
- 'addresses' : relation(Address,
+ 'addresses' : relationship(Address,
backref=backref("customer"))
})
@@ -865,18 +866,18 @@ class AmbiguousJoinInterpretedAsSelfRef(_base.MappedTest):
class ManualBackrefTest(_fixtures.FixtureTest):
- """Test explicit relations that are backrefs to each other."""
+ """Test explicit relationships that are backrefs to each other."""
run_inserts = None
@testing.resolve_artifact_names
def test_o2m(self):
mapper(User, users, properties={
- 'addresses':relation(Address, back_populates='user')
+ 'addresses':relationship(Address, back_populates='user')
})
mapper(Address, addresses, properties={
- 'user':relation(User, back_populates='addresses')
+ 'user':relationship(User, back_populates='addresses')
})
sess = create_session()
@@ -896,11 +897,11 @@ class ManualBackrefTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_invalid_key(self):
mapper(User, users, properties={
- 'addresses':relation(Address, back_populates='userr')
+ 'addresses':relationship(Address, back_populates='userr')
})
mapper(Address, addresses, properties={
- 'user':relation(User, back_populates='addresses')
+ 'user':relationship(User, back_populates='addresses')
})
assert_raises(sa.exc.InvalidRequestError, compile_mappers)
@@ -908,17 +909,17 @@ class ManualBackrefTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_invalid_target(self):
mapper(User, users, properties={
- 'addresses':relation(Address, back_populates='dingaling'),
+ 'addresses':relationship(Address, back_populates='dingaling'),
})
mapper(Dingaling, dingalings)
mapper(Address, addresses, properties={
- 'dingaling':relation(Dingaling)
+ 'dingaling':relationship(Dingaling)
})
assert_raises_message(sa.exc.ArgumentError,
- r"reverse_property 'dingaling' on relation User.addresses references "
- "relation Address.dingaling, which does not reference mapper Mapper\|User\|users",
+ r"reverse_property 'dingaling' on relationship User.addresses references "
+ "relationship Address.dingaling, which does not reference mapper Mapper\|User\|users",
compile_mappers)
class JoinConditionErrorTest(testing.TestBase):
@@ -933,7 +934,7 @@ class JoinConditionErrorTest(testing.TestBase):
__tablename__ = 'c2'
id = Column('id', Integer, primary_key=True)
c1id = Column('c1id', Integer, ForeignKey('c1.id'))
- c2 = relation(C1, primaryjoin=C1.id)
+ c2 = relationship(C1, primaryjoin=C1.id)
assert_raises(sa.exc.ArgumentError, compile_mappers)
@@ -947,7 +948,7 @@ class JoinConditionErrorTest(testing.TestBase):
__tablename__ = 'c2'
id = Column('id', Integer, primary_key=True)
c1id = Column('c1id', Integer, ForeignKey('c1.id'))
- c2 = relation(C1, primaryjoin="x"=="y")
+ c2 = relationship(C1, primaryjoin="x"=="y")
assert_raises(sa.exc.ArgumentError, compile_mappers)
@@ -965,7 +966,7 @@ class JoinConditionErrorTest(testing.TestBase):
class C2(object):
pass
- mapper(C1, t1, properties={'c2':relation(C2, primaryjoin=t1.join(t2))})
+ mapper(C1, t1, properties={'c2':relationship(C2, primaryjoin=t1.join(t2))})
mapper(C2, t2)
assert_raises(sa.exc.ArgumentError, compile_mappers)
@@ -989,7 +990,7 @@ class JoinConditionErrorTest(testing.TestBase):
class C2(object):
pass
- mapper(C1, t1, properties={'c2':relation(C2)})
+ mapper(C1, t1, properties={'c2':relationship(C2)})
mapper(C2, t3)
assert_raises(sa.exc.NoReferencedColumnError, compile_mappers)
@@ -1013,7 +1014,7 @@ class JoinConditionErrorTest(testing.TestBase):
class C2(object):
pass
- mapper(C1, t1, properties={'c2':relation(C2)})
+ mapper(C1, t1, properties={'c2':relationship(C2)})
mapper(C2, t3)
assert_raises(sa.exc.ArgumentError, compile_mappers)
@@ -1022,7 +1023,7 @@ class JoinConditionErrorTest(testing.TestBase):
clear_mappers()
class TypeMatchTest(_base.MappedTest):
- """test errors raised when trying to add items whose type is not handled by a relation"""
+ """test errors raised when trying to add items whose type is not handled by a relationship"""
@classmethod
def define_tables(cls, metadata):
@@ -1047,7 +1048,7 @@ class TypeMatchTest(_base.MappedTest):
class A(_base.Entity): pass
class B(_base.Entity): pass
class C(_base.Entity): pass
- mapper(A, a, properties={'bs':relation(B)})
+ mapper(A, a, properties={'bs':relationship(B)})
mapper(B, b)
mapper(C, c)
@@ -1070,7 +1071,7 @@ class TypeMatchTest(_base.MappedTest):
class A(_base.Entity): pass
class B(_base.Entity): pass
class C(_base.Entity): pass
- mapper(A, a, properties={'bs':relation(B, cascade="none")})
+ mapper(A, a, properties={'bs':relationship(B, cascade="none")})
mapper(B, b)
mapper(C, c)
@@ -1091,7 +1092,7 @@ class TypeMatchTest(_base.MappedTest):
class A(_base.Entity): pass
class B(_base.Entity): pass
class C(B): pass
- mapper(A, a, properties={'bs':relation(B, cascade="none")})
+ mapper(A, a, properties={'bs':relationship(B, cascade="none")})
mapper(B, b)
mapper(C, c, inherits=B)
@@ -1114,7 +1115,7 @@ class TypeMatchTest(_base.MappedTest):
class D(_base.Entity): pass
mapper(A, a)
mapper(B, b, inherits=A)
- mapper(D, d, properties={"a":relation(A, cascade="none")})
+ mapper(D, d, properties={"a":relationship(A, cascade="none")})
b1 = B()
d1 = D()
d1.a = b1
@@ -1131,7 +1132,7 @@ class TypeMatchTest(_base.MappedTest):
class D(_base.Entity): pass
mapper(A, a)
mapper(B, b)
- mapper(D, d, properties={"a":relation(A)})
+ mapper(D, d, properties={"a":relationship(A)})
b1 = B()
d1 = D()
d1.a = b1
@@ -1168,7 +1169,7 @@ class TypedAssociationTable(_base.MappedTest):
class T2(_base.Entity): pass
mapper(T2, t2)
mapper(T1, t1, properties={
- 't2s':relation(T2, secondary=t3, backref='t1s')})
+ 't2s':relationship(T2, secondary=t3, backref='t1s')})
a = T1()
a.col1 = "aid"
@@ -1210,7 +1211,7 @@ class ViewOnlyM2MBackrefTest(_base.MappedTest):
class B(_base.ComparableEntity):pass
mapper(A, t1, properties={
- 'bs':relation(B, secondary=t1t2, backref=backref('as_', viewonly=True))
+ 'bs':relationship(B, secondary=t1t2, backref=backref('as_', viewonly=True))
})
mapper(B, t2)
@@ -1258,15 +1259,15 @@ class ViewOnlyOverlappingNames(_base.MappedTest):
class C3(_base.Entity): pass
mapper(C1, t1, properties={
- 't2s':relation(C2),
- 't2_view':relation(C2,
+ 't2s':relationship(C2),
+ 't2_view':relationship(C2,
viewonly=True,
primaryjoin=sa.and_(t1.c.id==t2.c.t1id,
t3.c.t2id==t2.c.id,
t3.c.data==t1.c.data))})
mapper(C2, t2)
mapper(C3, t3, properties={
- 't2':relation(C2)})
+ 't2':relationship(C2)})
c1 = C1()
c1.data = 'c1data'
@@ -1317,15 +1318,15 @@ class ViewOnlyUniqueNames(_base.MappedTest):
class C3(_base.Entity): pass
mapper(C1, t1, properties={
- 't2s':relation(C2),
- 't2_view':relation(C2,
+ 't2s':relationship(C2),
+ 't2_view':relationship(C2,
viewonly=True,
primaryjoin=sa.and_(t1.c.t1id==t2.c.t1id_ref,
t3.c.t2id_ref==t2.c.t2id,
t3.c.data==t1.c.data))})
mapper(C2, t2)
mapper(C3, t3, properties={
- 't2':relation(C2)})
+ 't2':relationship(C2)})
c1 = C1()
c1.data = 'c1data'
@@ -1367,8 +1368,8 @@ class ViewOnlyLocalRemoteM2M(testing.TestBase):
class B(object): pass
mapper( B, t2, )
m = mapper( A, t1, properties=dict(
- b_view = relation( B, secondary=t12, viewonly=True),
- b_plain= relation( B, secondary=t12),
+ b_view = relationship( B, secondary=t12, viewonly=True),
+ b_plain= relationship( B, secondary=t12),
)
)
compile_mappers()
@@ -1397,7 +1398,7 @@ class ViewOnlyNonEquijoin(_base.MappedTest):
pass
mapper(Foo, foos, properties={
- 'bars':relation(Bar,
+ 'bars':relationship(Bar,
primaryjoin=foos.c.id > bars.c.fid,
foreign_keys=[bars.c.fid],
viewonly=True)})
@@ -1435,14 +1436,14 @@ class ViewOnlyRepeatedRemoteColumn(_base.MappedTest):
Column('data', String(50)))
@testing.resolve_artifact_names
- def test_relation_on_or(self):
+ def test_relationship_on_or(self):
class Foo(_base.ComparableEntity):
pass
class Bar(_base.ComparableEntity):
pass
mapper(Foo, foos, properties={
- 'bars':relation(Bar,
+ 'bars':relationship(Bar,
primaryjoin=sa.or_(bars.c.id == foos.c.bid1,
bars.c.id == foos.c.bid2),
uselist=True,
@@ -1483,14 +1484,14 @@ class ViewOnlyRepeatedLocalColumn(_base.MappedTest):
Column('data', String(50)))
@testing.resolve_artifact_names
- def test_relation_on_or(self):
+ def test_relationship_on_or(self):
class Foo(_base.ComparableEntity):
pass
class Bar(_base.ComparableEntity):
pass
mapper(Foo, foos, properties={
- 'bars':relation(Bar,
+ 'bars':relationship(Bar,
primaryjoin=sa.or_(bars.c.fid1 == foos.c.id,
bars.c.fid2 == foos.c.id),
viewonly=True)})
@@ -1547,7 +1548,7 @@ class ViewOnlyComplexJoin(_base.MappedTest):
@testing.resolve_artifact_names
def test_basic(self):
mapper(T1, t1, properties={
- 't3s':relation(T3, primaryjoin=sa.and_(
+ 't3s':relationship(T3, primaryjoin=sa.and_(
t1.c.id==t2.c.t1id,
t2.c.id==t2tot3.c.t2id,
t3.c.id==t2tot3.c.t3id),
@@ -1555,8 +1556,8 @@ class ViewOnlyComplexJoin(_base.MappedTest):
foreign_keys=t3.c.id, remote_side=t2.c.t1id)
})
mapper(T2, t2, properties={
- 't1':relation(T1),
- 't3s':relation(T3, secondary=t2tot3)
+ 't1':relationship(T1),
+ 't3s':relationship(T3, secondary=t2tot3)
})
mapper(T3, t3)
@@ -1572,7 +1573,7 @@ class ViewOnlyComplexJoin(_base.MappedTest):
@testing.resolve_artifact_names
def test_remote_side_escalation(self):
mapper(T1, t1, properties={
- 't3s':relation(T3,
+ 't3s':relationship(T3,
primaryjoin=sa.and_(t1.c.id==t2.c.t1id,
t2.c.id==t2tot3.c.t2id,
t3.c.id==t2tot3.c.t3id
@@ -1580,8 +1581,8 @@ class ViewOnlyComplexJoin(_base.MappedTest):
viewonly=True,
foreign_keys=t3.c.id)})
mapper(T2, t2, properties={
- 't1':relation(T1),
- 't3s':relation(T3, secondary=t2tot3)})
+ 't1':relationship(T1),
+ 't3s':relationship(T3, secondary=t2tot3)})
mapper(T3, t3)
assert_raises_message(sa.exc.ArgumentError,
"Specify remote_side argument",
@@ -1613,7 +1614,7 @@ class ExplicitLocalRemoteTest(_base.MappedTest):
# use a function within join condition. but specifying
# local_remote_pairs overrides all parsing of the join condition.
mapper(T1, t1, properties={
- 't2s':relation(T2,
+ 't2s':relationship(T2,
primaryjoin=t1.c.id==sa.func.lower(t2.c.t1id),
_local_remote_pairs=[(t1.c.id, t2.c.t1id)],
foreign_keys=[t2.c.t1id])})
@@ -1638,7 +1639,7 @@ class ExplicitLocalRemoteTest(_base.MappedTest):
def test_manytoone_funcfk(self):
mapper(T1, t1)
mapper(T2, t2, properties={
- 't1':relation(T1,
+ 't1':relationship(T1,
primaryjoin=t1.c.id==sa.func.lower(t2.c.t1id),
_local_remote_pairs=[(t2.c.t1id, t1.c.id)],
foreign_keys=[t2.c.t1id],
@@ -1661,7 +1662,7 @@ class ExplicitLocalRemoteTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_onetomany_func_referent(self):
mapper(T1, t1, properties={
- 't2s':relation(T2,
+ 't2s':relationship(T2,
primaryjoin=sa.func.lower(t1.c.id)==t2.c.t1id,
_local_remote_pairs=[(t1.c.id, t2.c.t1id)],
foreign_keys=[t2.c.t1id])})
@@ -1686,7 +1687,7 @@ class ExplicitLocalRemoteTest(_base.MappedTest):
def test_manytoone_func_referent(self):
mapper(T1, t1)
mapper(T2, t2, properties={
- 't1':relation(T1,
+ 't1':relationship(T1,
primaryjoin=sa.func.lower(t1.c.id)==t2.c.t1id,
_local_remote_pairs=[(t2.c.t1id, t1.c.id)],
foreign_keys=[t2.c.t1id], uselist=True)})
@@ -1708,7 +1709,7 @@ class ExplicitLocalRemoteTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_escalation_1(self):
mapper(T1, t1, properties={
- 't2s':relation(T2,
+ 't2s':relationship(T2,
primaryjoin=t1.c.id==sa.func.lower(t2.c.t1id),
_local_remote_pairs=[(t1.c.id, t2.c.t1id)],
foreign_keys=[t2.c.t1id],
@@ -1719,7 +1720,7 @@ class ExplicitLocalRemoteTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_escalation_2(self):
mapper(T1, t1, properties={
- 't2s':relation(T2,
+ 't2s':relationship(T2,
primaryjoin=t1.c.id==sa.func.lower(t2.c.t1id),
_local_remote_pairs=[(t1.c.id, t2.c.t1id)])})
mapper(T2, t2)
@@ -1743,7 +1744,7 @@ class InvalidRemoteSideTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_o2m_backref(self):
mapper(T1, t1, properties={
- 't1s':relation(T1, backref='parent')
+ 't1s':relationship(T1, backref='parent')
})
assert_raises_message(sa.exc.ArgumentError, "T1.t1s and back-reference T1.parent are "
@@ -1753,7 +1754,7 @@ class InvalidRemoteSideTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_m2o_backref(self):
mapper(T1, t1, properties={
- 't1s':relation(T1, backref=backref('parent', remote_side=t1.c.id), remote_side=t1.c.id)
+ 't1s':relationship(T1, backref=backref('parent', remote_side=t1.c.id), remote_side=t1.c.id)
})
assert_raises_message(sa.exc.ArgumentError, "T1.t1s and back-reference T1.parent are "
@@ -1763,8 +1764,8 @@ class InvalidRemoteSideTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_o2m_explicit(self):
mapper(T1, t1, properties={
- 't1s':relation(T1, back_populates='parent'),
- 'parent':relation(T1, back_populates='t1s'),
+ 't1s':relationship(T1, back_populates='parent'),
+ 'parent':relationship(T1, back_populates='t1s'),
})
# can't be sure of ordering here
@@ -1775,8 +1776,8 @@ class InvalidRemoteSideTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_m2o_explicit(self):
mapper(T1, t1, properties={
- 't1s':relation(T1, back_populates='parent', remote_side=t1.c.id),
- 'parent':relation(T1, back_populates='t1s', remote_side=t1.c.id)
+ 't1s':relationship(T1, back_populates='parent', remote_side=t1.c.id),
+ 'parent':relationship(T1, back_populates='t1s', remote_side=t1.c.id)
})
# can't be sure of ordering here
@@ -1785,7 +1786,7 @@ class InvalidRemoteSideTest(_base.MappedTest):
"mean to set remote_side on the many-to-one side ?", sa.orm.compile_mappers)
-class InvalidRelationEscalationTest(_base.MappedTest):
+class InvalidRelationshipEscalationTest(_base.MappedTest):
@classmethod
def define_tables(cls, metadata):
@@ -1806,41 +1807,41 @@ class InvalidRelationEscalationTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_no_join(self):
mapper(Foo, foos, properties={
- 'bars':relation(Bar)})
+ 'bars':relationship(Bar)})
mapper(Bar, bars)
assert_raises_message(
sa.exc.ArgumentError,
"Could not determine join condition between parent/child "
- "tables on relation", sa.orm.compile_mappers)
+ "tables on relationship", sa.orm.compile_mappers)
@testing.resolve_artifact_names
def test_no_join_self_ref(self):
mapper(Foo, foos, properties={
- 'foos':relation(Foo)})
+ 'foos':relationship(Foo)})
mapper(Bar, bars)
assert_raises_message(
sa.exc.ArgumentError,
"Could not determine join condition between parent/child "
- "tables on relation", sa.orm.compile_mappers)
+ "tables on relationship", sa.orm.compile_mappers)
@testing.resolve_artifact_names
def test_no_equated(self):
mapper(Foo, foos, properties={
- 'bars':relation(Bar,
+ 'bars':relationship(Bar,
primaryjoin=foos.c.id>bars.c.fid)})
mapper(Bar, bars)
assert_raises_message(
sa.exc.ArgumentError,
- "Could not determine relation direction for primaryjoin condition",
+ "Could not determine relationship direction for primaryjoin condition",
sa.orm.compile_mappers)
@testing.resolve_artifact_names
def test_no_equated_fks(self):
mapper(Foo, foos, properties={
- 'bars':relation(Bar,
+ 'bars':relationship(Bar,
primaryjoin=foos.c.id>bars.c.fid,
foreign_keys=bars.c.fid)})
mapper(Bar, bars)
@@ -1853,7 +1854,7 @@ class InvalidRelationEscalationTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_ambiguous_fks(self):
mapper(Foo, foos, properties={
- 'bars':relation(Bar,
+ 'bars':relationship(Bar,
primaryjoin=foos.c.id==bars.c.fid,
foreign_keys=[foos.c.id, bars.c.fid])})
mapper(Bar, bars)
@@ -1867,7 +1868,7 @@ class InvalidRelationEscalationTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_ambiguous_remoteside_o2m(self):
mapper(Foo, foos, properties={
- 'bars':relation(Bar,
+ 'bars':relationship(Bar,
primaryjoin=foos.c.id==bars.c.fid,
foreign_keys=[bars.c.fid],
remote_side=[foos.c.id, bars.c.fid],
@@ -1883,7 +1884,7 @@ class InvalidRelationEscalationTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_ambiguous_remoteside_m2o(self):
mapper(Foo, foos, properties={
- 'bars':relation(Bar,
+ 'bars':relationship(Bar,
primaryjoin=foos.c.id==bars.c.fid,
foreign_keys=[foos.c.id],
remote_side=[foos.c.id, bars.c.fid],
@@ -1900,19 +1901,19 @@ class InvalidRelationEscalationTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_no_equated_self_ref(self):
mapper(Foo, foos, properties={
- 'foos':relation(Foo,
+ 'foos':relationship(Foo,
primaryjoin=foos.c.id>foos.c.fid)})
mapper(Bar, bars)
assert_raises_message(
sa.exc.ArgumentError,
- "Could not determine relation direction for primaryjoin condition",
+ "Could not determine relationship direction for primaryjoin condition",
sa.orm.compile_mappers)
@testing.resolve_artifact_names
def test_no_equated_self_ref(self):
mapper(Foo, foos, properties={
- 'foos':relation(Foo,
+ 'foos':relationship(Foo,
primaryjoin=foos.c.id>foos.c.fid,
foreign_keys=[foos.c.fid])})
mapper(Bar, bars)
@@ -1925,20 +1926,20 @@ class InvalidRelationEscalationTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_no_equated_viewonly(self):
mapper(Foo, foos, properties={
- 'bars':relation(Bar,
+ 'bars':relationship(Bar,
primaryjoin=foos.c.id>bars.c.fid,
viewonly=True)})
mapper(Bar, bars)
assert_raises_message(
sa.exc.ArgumentError,
- "Could not determine relation direction for primaryjoin condition",
+ "Could not determine relationship direction for primaryjoin condition",
sa.orm.compile_mappers)
@testing.resolve_artifact_names
def test_no_equated_self_ref_viewonly(self):
mapper(Foo, foos, properties={
- 'foos':relation(Foo,
+ 'foos':relationship(Foo,
primaryjoin=foos.c.id>foos.c.fid,
viewonly=True)})
mapper(Bar, bars)
@@ -1946,12 +1947,12 @@ class InvalidRelationEscalationTest(_base.MappedTest):
assert_raises_message(
sa.exc.ArgumentError,
"Specify the 'foreign_keys' argument to indicate which columns "
- "on the relation are foreign.", sa.orm.compile_mappers)
+ "on the relationship are foreign.", sa.orm.compile_mappers)
@testing.resolve_artifact_names
def test_no_equated_self_ref_viewonly_fks(self):
mapper(Foo, foos, properties={
- 'foos':relation(Foo,
+ 'foos':relationship(Foo,
primaryjoin=foos.c.id>foos.c.fid,
viewonly=True,
foreign_keys=[foos.c.fid])})
@@ -1962,40 +1963,40 @@ class InvalidRelationEscalationTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_equated(self):
mapper(Foo, foos, properties={
- 'bars':relation(Bar,
+ 'bars':relationship(Bar,
primaryjoin=foos.c.id==bars.c.fid)})
mapper(Bar, bars)
assert_raises_message(
sa.exc.ArgumentError,
- "Could not determine relation direction for primaryjoin condition",
+ "Could not determine relationship direction for primaryjoin condition",
sa.orm.compile_mappers)
@testing.resolve_artifact_names
def test_equated_self_ref(self):
mapper(Foo, foos, properties={
- 'foos':relation(Foo,
+ 'foos':relationship(Foo,
primaryjoin=foos.c.id==foos.c.fid)})
assert_raises_message(
sa.exc.ArgumentError,
- "Could not determine relation direction for primaryjoin condition",
+ "Could not determine relationship direction for primaryjoin condition",
sa.orm.compile_mappers)
@testing.resolve_artifact_names
def test_equated_self_ref_wrong_fks(self):
mapper(Foo, foos, properties={
- 'foos':relation(Foo,
+ 'foos':relationship(Foo,
primaryjoin=foos.c.id==foos.c.fid,
foreign_keys=[bars.c.id])})
assert_raises_message(
sa.exc.ArgumentError,
- "Could not determine relation direction for primaryjoin condition",
+ "Could not determine relationship direction for primaryjoin condition",
sa.orm.compile_mappers)
-class InvalidRelationEscalationTestM2M(_base.MappedTest):
+class InvalidRelationshipEscalationTestM2M(_base.MappedTest):
@classmethod
def define_tables(cls, metadata):
@@ -2017,18 +2018,18 @@ class InvalidRelationEscalationTestM2M(_base.MappedTest):
@testing.resolve_artifact_names
def test_no_join(self):
mapper(Foo, foos, properties={
- 'bars': relation(Bar, secondary=foobars)})
+ 'bars': relationship(Bar, secondary=foobars)})
mapper(Bar, bars)
assert_raises_message(
sa.exc.ArgumentError,
"Could not determine join condition between parent/child tables "
- "on relation", sa.orm.compile_mappers)
+ "on relationship", sa.orm.compile_mappers)
@testing.resolve_artifact_names
def test_no_secondaryjoin(self):
mapper(Foo, foos, properties={
- 'bars': relation(Bar,
+ 'bars': relationship(Bar,
secondary=foobars,
primaryjoin=foos.c.id > foobars.c.fid)})
mapper(Bar, bars)
@@ -2036,13 +2037,13 @@ class InvalidRelationEscalationTestM2M(_base.MappedTest):
assert_raises_message(
sa.exc.ArgumentError,
"Could not determine join condition between parent/child tables "
- "on relation",
+ "on relationship",
sa.orm.compile_mappers)
@testing.resolve_artifact_names
def test_bad_primaryjoin(self):
mapper(Foo, foos, properties={
- 'bars': relation(Bar,
+ 'bars': relationship(Bar,
secondary=foobars,
primaryjoin=foos.c.id > foobars.c.fid,
secondaryjoin=foobars.c.bid<=bars.c.id)})
@@ -2050,13 +2051,13 @@ class InvalidRelationEscalationTestM2M(_base.MappedTest):
assert_raises_message(
sa.exc.ArgumentError,
- "Could not determine relation direction for primaryjoin condition",
+ "Could not determine relationship direction for primaryjoin condition",
sa.orm.compile_mappers)
@testing.resolve_artifact_names
def test_bad_secondaryjoin(self):
mapper(Foo, foos, properties={
- 'bars':relation(Bar,
+ 'bars':relationship(Bar,
secondary=foobars,
primaryjoin=foos.c.id == foobars.c.fid,
secondaryjoin=foobars.c.bid <= bars.c.id,
@@ -2065,13 +2066,13 @@ class InvalidRelationEscalationTestM2M(_base.MappedTest):
assert_raises_message(
sa.exc.ArgumentError,
- "Could not determine relation direction for secondaryjoin "
+ "Could not determine relationship direction for secondaryjoin "
"condition", sa.orm.compile_mappers)
@testing.resolve_artifact_names
def test_no_equated_secondaryjoin(self):
mapper(Foo, foos, properties={
- 'bars':relation(Bar,
+ 'bars':relationship(Bar,
secondary=foobars,
primaryjoin=foos.c.id == foobars.c.fid,
secondaryjoin=foobars.c.bid <= bars.c.id,
@@ -2084,3 +2085,59 @@ class InvalidRelationEscalationTestM2M(_base.MappedTest):
"secondaryjoin condition", sa.orm.compile_mappers)
+class RelationDeprecationTest(_base.MappedTest):
+ run_inserts = 'once'
+ run_deletes = None
+
+ @classmethod
+ def define_tables(cls, metadata):
+ Table('users_table', metadata,
+ Column('id', Integer, primary_key=True),
+ Column('name', String(64)))
+
+ Table('addresses_table', metadata,
+ Column('id', Integer, primary_key=True),
+ Column('user_id', Integer, ForeignKey('users_table.id')),
+ Column('email_address', String(128)),
+ Column('purpose', String(16)),
+ Column('bounces', Integer, default=0))
+
+ @classmethod
+ def setup_classes(cls):
+ class User(_base.BasicEntity):
+ pass
+
+ class Address(_base.BasicEntity):
+ pass
+
+ @classmethod
+ def fixtures(cls):
+ return dict(
+ users_table=(
+ ('id', 'name'),
+ (1, 'jack'),
+ (2, 'ed'),
+ (3, 'fred'),
+ (4, 'chuck')),
+
+ addresses_table=(
+ ('id', 'user_id', 'email_address', 'purpose', 'bounces'),
+ (1, 1, 'jack@jack.home', 'Personal', 0),
+ (2, 1, 'jack@jack.bizz', 'Work', 1),
+ (3, 2, 'ed@foo.bar', 'Personal', 0),
+ (4, 3, 'fred@the.fred', 'Personal', 10)))
+
+ @testing.resolve_artifact_names
+ def test_relation(self):
+ mapper(User, users_table, properties=dict(
+ addresses=relation(Address, backref='user'),
+ ))
+ mapper(Address, addresses_table)
+
+ session = create_session()
+
+ ed = session.query(User).filter(User.addresses.any(
+ Address.email_address == 'ed@foo.bar')).one()
+
+
+
diff --git a/test/orm/test_scoping.py b/test/orm/test_scoping.py
index 0d6b3deae..7db74308b 100644
--- a/test/orm/test_scoping.py
+++ b/test/orm/test_scoping.py
@@ -4,7 +4,7 @@ from sqlalchemy.test import testing
from sqlalchemy.orm import scoped_session
from sqlalchemy import Integer, String, ForeignKey
from sqlalchemy.test.schema import Table, Column
-from sqlalchemy.orm import mapper, relation, query
+from sqlalchemy.orm import mapper, relationship, query
from sqlalchemy.test.testing import eq_
from test.orm import _base
@@ -54,7 +54,7 @@ class ScopedSessionTest(_base.MappedTest):
custom_query = Session.query_property(query_cls=CustomQuery)
mapper(SomeObject, table1, properties={
- 'options':relation(SomeOtherObject)})
+ 'options':relationship(SomeOtherObject)})
mapper(SomeOtherObject, table2)
s = SomeObject(id=1, data="hello")
@@ -101,7 +101,7 @@ class ScopedMapperTest(_ScopedTest):
def setup_mappers(cls):
Session = scoped_session(sa.orm.create_session)
Session.mapper(SomeObject, table1, properties={
- 'options':relation(SomeOtherObject)
+ 'options':relationship(SomeOtherObject)
})
Session.mapper(SomeOtherObject, table2)
diff --git a/test/orm/test_session.py b/test/orm/test_session.py
index de5ac7c0c..831707278 100644
--- a/test/orm/test_session.py
+++ b/test/orm/test_session.py
@@ -8,7 +8,7 @@ import sqlalchemy as sa
from sqlalchemy.test import engines, testing, config
from sqlalchemy import Integer, String, Sequence
from sqlalchemy.test.schema import Table, Column
-from sqlalchemy.orm import mapper, relation, backref, eagerload
+from sqlalchemy.orm import mapper, relationship, backref, eagerload
from sqlalchemy.test.testing import eq_
from test.engine import _base as engine_base
from test.orm import _base, _fixtures
@@ -80,7 +80,7 @@ class SessionTest(_fixtures.FixtureTest):
def test_expunge_cascade(self):
mapper(Address, addresses)
mapper(User, users, properties={
- 'addresses':relation(Address,
+ 'addresses':relationship(Address,
backref=backref("user", cascade="all"),
cascade="all")})
@@ -113,7 +113,7 @@ class SessionTest(_fixtures.FixtureTest):
mapper(Address, addresses_unbound)
mapper(User, users_unbound, properties={
- 'addresses':relation(Address,
+ 'addresses':relationship(Address,
backref=backref("user", cascade="all"),
cascade="all")})
@@ -150,7 +150,7 @@ class SessionTest(_fixtures.FixtureTest):
mapper(Address, addresses_unbound)
mapper(User, users_unbound, properties={
- 'addresses':relation(Address,
+ 'addresses':relationship(Address,
backref=backref("user", cascade="all"),
cascade="all")})
@@ -258,7 +258,7 @@ class SessionTest(_fixtures.FixtureTest):
"""
mapper(User, users, properties={
- 'addresses':relation(Address, backref="user")})
+ 'addresses':relationship(Address, backref="user")})
mapper(Address, addresses)
sess = create_session(autoflush=True, autocommit=False)
@@ -320,7 +320,7 @@ class SessionTest(_fixtures.FixtureTest):
def test_autoflush_rollback(self):
mapper(Address, addresses)
mapper(User, users, properties={
- 'addresses':relation(Address)})
+ 'addresses':relationship(Address)})
_fixtures.run_inserts_for(users)
_fixtures.run_inserts_for(addresses)
@@ -707,7 +707,7 @@ class SessionTest(_fixtures.FixtureTest):
s = create_session()
mapper(User, users, properties={
- 'addresses':relation(Address, cascade="all, delete")
+ 'addresses':relationship(Address, cascade="all, delete")
})
mapper(Address, addresses)
@@ -759,7 +759,7 @@ class SessionTest(_fixtures.FixtureTest):
def test_is_modified(self):
s = create_session()
- mapper(User, users, properties={'addresses':relation(Address)})
+ mapper(User, users, properties={'addresses':relationship(Address)})
mapper(Address, addresses)
# save user
@@ -883,7 +883,7 @@ class SessionTest(_fixtures.FixtureTest):
def test_weakref_with_cycles_o2m(self):
s = sessionmaker()()
mapper(User, users, properties={
- "addresses":relation(Address, backref="user")
+ "addresses":relationship(Address, backref="user")
})
mapper(Address, addresses)
s.add(User(name="ed", addresses=[Address(email_address="ed1")]))
@@ -912,7 +912,7 @@ class SessionTest(_fixtures.FixtureTest):
def test_weakref_with_cycles_o2o(self):
s = sessionmaker()()
mapper(User, users, properties={
- "address":relation(Address, backref="user", uselist=False)
+ "address":relationship(Address, backref="user", uselist=False)
})
mapper(Address, addresses)
s.add(User(name="ed", address=Address(email_address="ed1")))
@@ -1013,7 +1013,7 @@ class SessionTest(_fixtures.FixtureTest):
def test_no_save_cascade_1(self):
mapper(Address, addresses)
mapper(User, users, properties=dict(
- addresses=relation(Address, cascade="none", backref="user")))
+ addresses=relationship(Address, cascade="none", backref="user")))
s = create_session()
u = User(name='u1')
@@ -1032,7 +1032,7 @@ class SessionTest(_fixtures.FixtureTest):
def test_no_save_cascade_2(self):
mapper(Address, addresses)
mapper(User, users, properties=dict(
- addresses=relation(Address,
+ addresses=relationship(Address,
cascade="all",
backref=backref("user", cascade="none"))))
diff --git a/test/orm/test_transaction.py b/test/orm/test_transaction.py
index 7022a9faa..2617f12f0 100644
--- a/test/orm/test_transaction.py
+++ b/test/orm/test_transaction.py
@@ -18,7 +18,7 @@ class TransactionTest(FixtureTest):
@classmethod
def setup_mappers(cls):
mapper(User, users, properties={
- 'addresses':relation(Address, backref='user',
+ 'addresses':relationship(Address, backref='user',
cascade="all, delete-orphan", order_by=addresses.c.id),
})
mapper(Address, addresses)
diff --git a/test/orm/test_unitofwork.py b/test/orm/test_unitofwork.py
index e1150a620..1a0158035 100644
--- a/test/orm/test_unitofwork.py
+++ b/test/orm/test_unitofwork.py
@@ -11,7 +11,7 @@ from sqlalchemy.test import engines, testing, pickleable
from sqlalchemy import Integer, String, ForeignKey, literal_column
from sqlalchemy.test.schema import Table
from sqlalchemy.test.schema import Column
-from sqlalchemy.orm import mapper, relation, create_session, column_property
+from sqlalchemy.orm import mapper, relationship, create_session, column_property
from sqlalchemy.test.testing import eq_, ne_
from test.orm import _base, _fixtures
from test.engine import _base as engine_base
@@ -35,7 +35,7 @@ class HistoryTest(_fixtures.FixtureTest):
def test_backref(self):
am = mapper(Address, addresses)
m = mapper(User, users, properties=dict(
- addresses = relation(am, backref='user', lazy=False)))
+ addresses = relationship(am, backref='user', lazy=False)))
session = create_session(autocommit=False)
@@ -94,9 +94,9 @@ class UnicodeTest(_base.MappedTest):
self.assert_(t1.txt == txt)
@testing.resolve_artifact_names
- def test_relation(self):
+ def test_relationship(self):
mapper(Test, uni_t1, properties={
- 't2s': relation(Test2)})
+ 't2s': relationship(Test2)})
mapper(Test2, uni_t2)
txt = u"\u0160\u0110\u0106\u010c\u017d"
@@ -156,7 +156,7 @@ class UnicodeSchemaTest(engine_base.AltEngineTest, _base.MappedTest):
pass
mapper(A, t1, properties={
- 't2s':relation(B)})
+ 't2s':relationship(B)})
mapper(B, t2)
a1 = A()
@@ -542,7 +542,7 @@ class ForeignPKTest(_base.MappedTest):
def test_basic(self):
m1 = mapper(PersonSite, peoplesites)
m2 = mapper(Person, people, properties={
- 'sites' : relation(PersonSite)})
+ 'sites' : relationship(PersonSite)})
sa.orm.compile_mappers()
eq_(list(m2.get_property('sites').synchronize_pairs),
@@ -661,7 +661,7 @@ class PassiveDeletesTest(_base.MappedTest):
def test_basic(self):
mapper(MyOtherClass, myothertable)
mapper(MyClass, mytable, properties={
- 'children':relation(MyOtherClass,
+ 'children':relationship(MyOtherClass,
passive_deletes=True,
cascade="all")})
session = create_session()
@@ -688,7 +688,7 @@ class PassiveDeletesTest(_base.MappedTest):
# the unusual scenario where a trigger or something might be deleting
# a many-to-one on deletion of the parent row
mapper(MyOtherClass, myothertable, properties={
- 'myclass':relation(MyClass, cascade="all, delete", passive_deletes=True)
+ 'myclass':relationship(MyClass, cascade="all, delete", passive_deletes=True)
})
mapper(MyClass, mytable)
@@ -740,7 +740,7 @@ class ExtraPassiveDeletesTest(_base.MappedTest):
mapper(MyOtherClass, myothertable)
try:
mapper(MyClass, mytable, properties={
- 'children':relation(MyOtherClass,
+ 'children':relationship(MyOtherClass,
passive_deletes='all',
cascade="all")})
assert False
@@ -753,7 +753,7 @@ class ExtraPassiveDeletesTest(_base.MappedTest):
def test_extra_passive(self):
mapper(MyOtherClass, myothertable)
mapper(MyClass, mytable, properties={
- 'children': relation(MyOtherClass,
+ 'children': relationship(MyOtherClass,
passive_deletes='all',
cascade="save-update")})
@@ -776,7 +776,7 @@ class ExtraPassiveDeletesTest(_base.MappedTest):
def test_extra_passive_2(self):
mapper(MyOtherClass, myothertable)
mapper(MyClass, mytable, properties={
- 'children': relation(MyOtherClass,
+ 'children': relationship(MyOtherClass,
passive_deletes='all',
cascade="save-update")})
@@ -946,11 +946,11 @@ class DefaultTest(_base.MappedTest):
@testing.fails_on('firebird', 'Data type unknown on the parameter')
@testing.resolve_artifact_names
- def test_used_in_relation(self):
+ def test_used_in_relationship(self):
"""A server-side default can be used as the target of a foreign key"""
mapper(Hoho, default_t, properties={
- 'secondaries':relation(Secondary, order_by=secondary_table.c.id)})
+ 'secondaries':relationship(Secondary, order_by=secondary_table.c.id)})
mapper(Secondary, secondary_table)
h1 = Hoho()
@@ -1052,7 +1052,7 @@ class OneToManyTest(_fixtures.FixtureTest):
"""Basic save of one to many."""
m = mapper(User, users, properties=dict(
- addresses = relation(mapper(Address, addresses), lazy=True)
+ addresses = relationship(mapper(Address, addresses), lazy=True)
))
u = User(name= 'one2manytester')
a = Address(email_address='one2many@test.org')
@@ -1092,7 +1092,7 @@ class OneToManyTest(_fixtures.FixtureTest):
"""Modifying the child items of an object."""
m = mapper(User, users, properties=dict(
- addresses = relation(mapper(Address, addresses), lazy=True)))
+ addresses = relationship(mapper(Address, addresses), lazy=True)))
u1 = User(name='user1')
u1.addresses = []
@@ -1140,7 +1140,7 @@ class OneToManyTest(_fixtures.FixtureTest):
"""
m = mapper(User, users, properties=dict(
- addresses = relation(mapper(Address, addresses), lazy=True)))
+ addresses = relationship(mapper(Address, addresses), lazy=True)))
u1 = User(name='user1')
u2 = User(name='user2')
@@ -1164,7 +1164,7 @@ class OneToManyTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_child_move_2(self):
m = mapper(User, users, properties=dict(
- addresses = relation(mapper(Address, addresses), lazy=True)))
+ addresses = relationship(mapper(Address, addresses), lazy=True)))
u1 = User(name='user1')
u2 = User(name='user2')
@@ -1187,7 +1187,7 @@ class OneToManyTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_o2m_delete_parent(self):
m = mapper(User, users, properties=dict(
- address = relation(mapper(Address, addresses),
+ address = relationship(mapper(Address, addresses),
lazy=True,
uselist=False)))
@@ -1210,7 +1210,7 @@ class OneToManyTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_one_to_one(self):
m = mapper(User, users, properties=dict(
- address = relation(mapper(Address, addresses),
+ address = relationship(mapper(Address, addresses),
lazy=True,
uselist=False)))
@@ -1231,7 +1231,7 @@ class OneToManyTest(_fixtures.FixtureTest):
def test_bidirectional(self):
m1 = mapper(User, users)
m2 = mapper(Address, addresses, properties=dict(
- user = relation(m1, lazy=False, backref='addresses')))
+ user = relationship(m1, lazy=False, backref='addresses')))
u = User(name='test')
@@ -1244,13 +1244,13 @@ class OneToManyTest(_fixtures.FixtureTest):
session.flush()
@testing.resolve_artifact_names
- def test_double_relation(self):
+ def test_double_relationship(self):
m2 = mapper(Address, addresses)
m = mapper(User, users, properties={
- 'boston_addresses' : relation(m2, primaryjoin=
+ 'boston_addresses' : relationship(m2, primaryjoin=
sa.and_(users.c.id==addresses.c.user_id,
addresses.c.email_address.like('%boston%'))),
- 'newyork_addresses' : relation(m2, primaryjoin=
+ 'newyork_addresses' : relationship(m2, primaryjoin=
sa.and_(users.c.id==addresses.c.user_id,
addresses.c.email_address.like('%newyork%')))})
@@ -1332,14 +1332,14 @@ class SaveTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_lazyattr_commit(self):
- """Lazily loaded relations.
+ """Lazily loaded relationships.
When a lazy-loaded list is unloaded, and a commit occurs, that the
'passive' call on that list does not blow away its value
"""
mapper(User, users, properties = {
- 'addresses': relation(mapper(Address, addresses))})
+ 'addresses': relationship(mapper(Address, addresses))})
u = User(name='u1')
u.addresses.append(Address(email_address='u1@e1'))
@@ -1486,7 +1486,7 @@ class SaveTest(_fixtures.FixtureTest):
def test_history_get(self):
"""The history lazy-fetches data when it wasn't otherwise loaded."""
mapper(User, users, properties={
- 'addresses':relation(Address, cascade="all, delete-orphan")})
+ 'addresses':relationship(Address, cascade="all, delete-orphan")})
mapper(Address, addresses)
u = User(name='u1')
@@ -1550,7 +1550,7 @@ class ManyToOneTest(_fixtures.FixtureTest):
def test_m2o_one_to_one(self):
# TODO: put assertion in here !!!
m = mapper(Address, addresses, properties=dict(
- user = relation(mapper(User, users), lazy=True, uselist=False)))
+ user = relationship(mapper(User, users), lazy=True, uselist=False)))
session = create_session()
@@ -1601,7 +1601,7 @@ class ManyToOneTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_many_to_one_1(self):
m = mapper(Address, addresses, properties=dict(
- user = relation(mapper(User, users), lazy=True)))
+ user = relationship(mapper(User, users), lazy=True)))
a1 = Address(email_address='emailaddress1')
u1 = User(name='user1')
@@ -1626,7 +1626,7 @@ class ManyToOneTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_many_to_one_2(self):
m = mapper(Address, addresses, properties=dict(
- user = relation(mapper(User, users), lazy=True)))
+ user = relationship(mapper(User, users), lazy=True)))
a1 = Address(email_address='emailaddress1')
a2 = Address(email_address='emailaddress2')
@@ -1657,7 +1657,7 @@ class ManyToOneTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_many_to_one_3(self):
m = mapper(Address, addresses, properties=dict(
- user = relation(mapper(User, users), lazy=True)))
+ user = relationship(mapper(User, users), lazy=True)))
a1 = Address(email_address='emailaddress1')
u1 = User(name='user1')
@@ -1685,7 +1685,7 @@ class ManyToOneTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_bidirectional_no_load(self):
mapper(User, users, properties={
- 'addresses':relation(Address, backref='user', lazy=None)})
+ 'addresses':relationship(Address, backref='user', lazy=None)})
mapper(Address, addresses)
# try it on unsaved objects
@@ -1715,7 +1715,7 @@ class ManyToManyTest(_fixtures.FixtureTest):
mapper(Keyword, keywords)
m = mapper(Item, items, properties=dict(
- keywords=relation(Keyword,
+ keywords=relationship(Keyword,
item_keywords,
lazy=False,
order_by=keywords.c.name)))
@@ -1823,7 +1823,7 @@ class ManyToManyTest(_fixtures.FixtureTest):
"""
mapper(Keyword, keywords)
mapper(Item, items, properties=dict(
- keywords = relation(Keyword, item_keywords, lazy=False),
+ keywords = relationship(Keyword, item_keywords, lazy=False),
))
i = Item(description='i1')
@@ -1843,12 +1843,12 @@ class ManyToManyTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_scalar(self):
- """sa.dependency won't delete an m2m relation referencing None."""
+ """sa.dependency won't delete an m2m relationship referencing None."""
mapper(Keyword, keywords)
mapper(Item, items, properties=dict(
- keyword=relation(Keyword, secondary=item_keywords, uselist=False)))
+ keyword=relationship(Keyword, secondary=item_keywords, uselist=False)))
i = Item(description='x')
session = create_session()
@@ -1862,7 +1862,7 @@ class ManyToManyTest(_fixtures.FixtureTest):
"""Assorted history operations on a many to many"""
mapper(Keyword, keywords)
mapper(Item, items, properties=dict(
- keywords=relation(Keyword,
+ keywords=relationship(Keyword,
secondary=item_keywords,
lazy=False,
order_by=keywords.c.name)))
@@ -1903,15 +1903,15 @@ class ManyToManyTest(_fixtures.FixtureTest):
mapper(IKAssociation, item_keywords,
primary_key=[item_keywords.c.item_id, item_keywords.c.keyword_id],
properties=dict(
- keyword=relation(mapper(Keyword, keywords, non_primary=True),
+ keyword=relationship(mapper(Keyword, keywords, non_primary=True),
lazy=False,
uselist=False,
order_by=keywords.c.name # note here is a valid place where order_by can be used
- ))) # on a scalar relation(); to determine eager ordering of
+ ))) # on a scalar relationship(); to determine eager ordering of
# the parent object within its collection.
mapper(Item, items, properties=dict(
- keywords=relation(IKAssociation, lazy=False)))
+ keywords=relationship(IKAssociation, lazy=False)))
session = create_session()
@@ -1946,7 +1946,7 @@ class SaveTest2(_fixtures.FixtureTest):
def test_m2o_nonmatch(self):
mapper(User, users)
mapper(Address, addresses, properties=dict(
- user = relation(User, lazy=True, uselist=False)))
+ user = relationship(User, lazy=True, uselist=False)))
session = create_session()
@@ -2003,7 +2003,7 @@ class SaveTest3(_base.MappedTest):
mapper(Keyword, keywords)
mapper(Item, items, properties=dict(
- keywords = relation(Keyword, secondary=assoc, lazy=False),))
+ keywords = relationship(Keyword, secondary=assoc, lazy=False),))
i = Item()
k1 = Keyword()
@@ -2102,7 +2102,7 @@ class RowSwitchTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_onetomany(self):
mapper(T5, t5, properties={
- 't6s':relation(T6, cascade="all, delete-orphan")
+ 't6s':relationship(T6, cascade="all, delete-orphan")
})
mapper(T6, t6)
@@ -2144,7 +2144,7 @@ class RowSwitchTest(_base.MappedTest):
@testing.resolve_artifact_names
def test_manytomany(self):
mapper(T5, t5, properties={
- 't7s':relation(T7, secondary=t5t7, cascade="all")
+ 't7s':relationship(T7, secondary=t5t7, cascade="all")
})
mapper(T7, t7)
@@ -2176,7 +2176,7 @@ class RowSwitchTest(_base.MappedTest):
def test_manytoone(self):
mapper(T6, t6, properties={
- 't5':relation(T5)
+ 't5':relationship(T5)
})
mapper(T5, t5)
diff --git a/test/orm/test_versioning.py b/test/orm/test_versioning.py
index e97a3ad98..d10a4c2bb 100644
--- a/test/orm/test_versioning.py
+++ b/test/orm/test_versioning.py
@@ -2,7 +2,7 @@ import sqlalchemy as sa
from sqlalchemy.test import engines, testing
from sqlalchemy import Integer, String, ForeignKey, literal_column, orm
from sqlalchemy.test.schema import Table, Column
-from sqlalchemy.orm import mapper, relation, create_session, column_property, sessionmaker
+from sqlalchemy.orm import mapper, relationship, create_session, column_property, sessionmaker
from sqlalchemy.test.testing import eq_, ne_, assert_raises, assert_raises_message
from test.orm import _base, _fixtures
from test.engine import _base as engine_base
@@ -180,7 +180,7 @@ class RowSwitchTest(_base.MappedTest):
def setup_mappers(cls):
mapper(P, p, version_id_col=p.c.version_id,
properties={
- 'c':relation(C, uselist=False, cascade='all, delete-orphan')
+ 'c':relationship(C, uselist=False, cascade='all, delete-orphan')
})
mapper(C, c, version_id_col=c.c.version_id)
@@ -240,7 +240,7 @@ class AlternateGeneratorTest(_base.MappedTest):
mapper(P, p, version_id_col=p.c.version_id,
version_id_generator=lambda x:make_uuid(),
properties={
- 'c':relation(C, uselist=False, cascade='all, delete-orphan')
+ 'c':relationship(C, uselist=False, cascade='all, delete-orphan')
})
mapper(C, c, version_id_col=c.c.version_id,
version_id_generator=lambda x:make_uuid(),
diff --git a/test/perf/cascade_speed.py b/test/perf/cascade_speed.py
index dbf41a7f7..a8beab2b2 100644
--- a/test/perf/cascade_speed.py
+++ b/test/perf/cascade_speed.py
@@ -30,13 +30,13 @@ class Value(object): pass
valueMapper = mapper(Value, values)
attrMapper = mapper(Attribute, attributes, properties=dict(
- values=relation(valueMapper, cascade="save-update", backref="attribute")
+ values=relationship(valueMapper, cascade="save-update", backref="attribute")
))
itemMapper = mapper(Item, items, properties=dict(
- attributes=relation(attrMapper, cascade="save-update", backref="item")
+ attributes=relationship(attrMapper, cascade="save-update", backref="item")
))
orderMapper = mapper(Order, orders, properties=dict(
- items=relation(itemMapper, cascade="save-update", backref="order")
+ items=relationship(itemMapper, cascade="save-update", backref="order")
))
diff --git a/test/perf/masseagerload.py b/test/perf/masseagerload.py
index 83140643c..3d251c816 100644
--- a/test/perf/masseagerload.py
+++ b/test/perf/masseagerload.py
@@ -17,7 +17,7 @@ subitems = Table('subitems', meta,
class Item(object):pass
class SubItem(object):pass
-mapper(Item, items, properties={'subs':relation(SubItem, lazy=False)})
+mapper(Item, items, properties={'subs':relationship(SubItem, lazy=False)})
mapper(SubItem, subitems)
def load():
diff --git a/test/perf/massload2.py b/test/perf/massload2.py
index a3deb932f..9182f1cd6 100644
--- a/test/perf/massload2.py
+++ b/test/perf/massload2.py
@@ -38,13 +38,13 @@ cascade = "all, delete-orphan"
use_backref = True
if use_backref:
- class_mapper(T1).add_property( 't2s', relation(T2, backref=backref("t1", cascade=cascade), cascade=cascade))
- class_mapper(T2).add_property ( 't3s', relation(T3, backref=backref("t2",cascade=cascade), cascade=cascade) )
- class_mapper(T3).add_property( 't4s', relation(T4, backref=backref("t3", cascade=cascade), cascade=cascade) )
+ class_mapper(T1).add_property( 't2s', relationship(T2, backref=backref("t1", cascade=cascade), cascade=cascade))
+ class_mapper(T2).add_property ( 't3s', relationship(T3, backref=backref("t2",cascade=cascade), cascade=cascade) )
+ class_mapper(T3).add_property( 't4s', relationship(T4, backref=backref("t3", cascade=cascade), cascade=cascade) )
else:
- T1.mapper.add_property( 't2s', relation(T2, cascade=cascade))
- T2.mapper.add_property ( 't3s', relation(T3, cascade=cascade) )
- T3.mapper.add_property( 't4s', relation(T4, cascade=cascade) )
+ T1.mapper.add_property( 't2s', relationship(T2, cascade=cascade))
+ T2.mapper.add_property ( 't3s', relationship(T3, cascade=cascade) )
+ T3.mapper.add_property( 't4s', relationship(T4, cascade=cascade) )
now = time.time()
print "start"
diff --git a/test/perf/objupdatespeed.py b/test/perf/objupdatespeed.py
index 52224211a..f98873afd 100644
--- a/test/perf/objupdatespeed.py
+++ b/test/perf/objupdatespeed.py
@@ -27,7 +27,7 @@ class Email(object):
getattr(self, 'address', None))
mapper(Person, Person_table, properties={
- 'emails': relation(Email, backref='owner', lazy=False)
+ 'emails': relationship(Email, backref='owner', lazy=False)
})
mapper(Email, Email_table)
compile_mappers()
diff --git a/test/perf/ormsession.py b/test/perf/ormsession.py
index f9f9dee8b..fc3e2e206 100644
--- a/test/perf/ormsession.py
+++ b/test/perf/ormsession.py
@@ -61,14 +61,14 @@ def define_tables():
@profiled('mapper')
def setup_mappers():
mapper(Item, items, properties={
- 'subitems': relation(SubItem, backref='item', lazy=True)
+ 'subitems': relationship(SubItem, backref='item', lazy=True)
})
mapper(SubItem, subitems)
mapper(Customer, customers, properties={
- 'purchases': relation(Purchase, lazy=True, backref='customer')
+ 'purchases': relationship(Purchase, lazy=True, backref='customer')
})
mapper(Purchase, purchases, properties={
- 'items': relation(Item, lazy=True, secondary=purchaseitems)
+ 'items': relationship(Item, lazy=True, secondary=purchaseitems)
})
@profiled('inserts')
diff --git a/test/perf/sessions.py b/test/perf/sessions.py
index 0d4cc1f01..4210732d6 100644
--- a/test/perf/sessions.py
+++ b/test/perf/sessions.py
@@ -42,7 +42,7 @@ class SessionTest(TestBase, AssertsExecutionResults):
pass
mapper(T1, t1, properties={
- 't2s':relation(T2, backref='t1')
+ 't2s':relationship(T2, backref='t1')
})
mapper(T2, t2)
diff --git a/test/perf/threaded_compile.py b/test/perf/threaded_compile.py
index e0252403a..0facf0ec2 100644
--- a/test/perf/threaded_compile.py
+++ b/test/perf/threaded_compile.py
@@ -62,7 +62,7 @@ def run3():
foo()
time.sleep(.05)
-mapper(T1, t1, properties={'t2':relation(T2, backref="t1")})
+mapper(T1, t1, properties={'t2':relationship(T2, backref="t1")})
mapper(T2, t2)
print "START"
for j in range(0, 5):
diff --git a/test/zblog/mappers.py b/test/zblog/mappers.py
index 126d2c568..45d101512 100644
--- a/test/zblog/mappers.py
+++ b/test/zblog/mappers.py
@@ -22,7 +22,7 @@ def zblog_mappers():
# ways. this will also attach a 'blogs' property to the user mapper.
mapper(Blog, tables.blogs, properties={
'id':tables.blogs.c.blog_id,
- 'owner':relation(user.User, lazy=False,
+ 'owner':relationship(user.User, lazy=False,
backref=backref('blogs', cascade="all, delete-orphan")),
})
@@ -38,7 +38,7 @@ def zblog_mappers():
primary_key=[tables.topic_xref.c.post_id,
tables.topic_xref.c.topic_id],
properties={
- 'topic':relation(Topic, lazy=False),
+ 'topic':relationship(Topic, lazy=False),
})
# Post mapper, these are posts within a blog.
@@ -66,11 +66,11 @@ def zblog_mappers():
mapper(Post, posts_with_ccount, properties={
'id':posts_with_ccount.c.post_id,
'body':deferred(tables.posts.c.body),
- 'user':relation(user.User, lazy=True,
+ 'user':relationship(user.User, lazy=True,
backref=backref('posts', cascade="all, delete-orphan")),
- 'blog':relation(Blog, lazy=True,
+ 'blog':relationship(Blog, lazy=True,
backref=backref('posts', cascade="all, delete-orphan")),
- 'topics':relation(TopicAssociation, lazy=False,
+ 'topics':relationship(TopicAssociation, lazy=False,
cascade="all, delete-orphan",
backref='post')
}, order_by=[desc(posts_with_ccount.c.datetime)])
@@ -81,18 +81,18 @@ def zblog_mappers():
# list of child comments.
mapper(Comment, tables.comments, properties={
'id':tables.comments.c.comment_id,
- 'post':relation(Post, lazy=True,
+ 'post':relationship(Post, lazy=True,
backref=backref('comments',
cascade="all, delete-orphan")),
- 'user':relation(user.User, lazy=False,
+ 'user':relationship(user.User, lazy=False,
backref=backref('comments',
cascade="all, delete-orphan")),
- 'parent':relation(Comment,
+ 'parent':relationship(Comment,
primaryjoin=(tables.comments.c.parent_comment_id ==
tables.comments.c.comment_id),
foreign_keys=[tables.comments.c.comment_id],
lazy=True, uselist=False),
- 'replies':relation(Comment,
+ 'replies':relationship(Comment,
primaryjoin=(tables.comments.c.parent_comment_id ==
tables.comments.c.comment_id),
lazy=True, uselist=True, cascade="all"),