if include_removes:
event.listen(desc, "remove", remove, raw=True, retval=True)
-def polymorphic_union(table_map, typecolname, aliasname='p_union', cast_nulls=True):
+def polymorphic_union(table_map, typecolname,
+ aliasname='p_union', cast_nulls=True):
"""Create a ``UNION`` statement used by a polymorphic mapper.
See :ref:`concrete_inheritance` for an example of how
:param table_map: mapping of polymorphic identities to
:class:`.Table` objects.
:param typecolname: string name of a "discriminator" column, which will be
- derived from the query, producing the polymorphic identity for each row. If
- ``None``, no polymorphic discriminator is generated.
+ derived from the query, producing the polymorphic identity for
+ each row. If ``None``, no polymorphic discriminator is generated.
:param aliasname: name of the :func:`~sqlalchemy.sql.expression.alias()`
construct generated.
- :param cast_nulls: if True, non-existent columns, which are represented as labeled
- NULLs, will be passed into CAST. This is a legacy behavior that is problematic
- on some backends such as Oracle - in which case it can be set to False.
+ :param cast_nulls: if True, non-existent columns, which are represented
+ as labeled NULLs, will be passed into CAST. This is a legacy behavior
+ that is problematic on some backends such as Oracle - in which case it
+ can be set to False.
"""
@classmethod
def coerce(cls, raw):
- return util.reduce(lambda prev, next:prev[next], raw, cls.root)
+ return util.reduce(lambda prev, next: prev[next], raw, cls.root)
@classmethod
def token(cls, token):
def __add__(self, other):
return util.reduce(
- lambda prev, next:prev[next],
+ lambda prev, next: prev[next],
other.path, self)
def __repr__(self):
# bigger operation so using a small variance
@profiling.function_call_count(variance=0.05,
- versions={'2.7':93, '2.6':93, '2.5':94, '3': 100})
+ versions={'2.7':96, '2.6':96, '2.5':96, '3': 100})
def go():
return sess2.merge(p1, load=False)
p2 = go()
# third call, merge object already present. almost no calls.
@profiling.function_call_count(variance=0.05,
- versions={'2.7':15, '2.6':15, '2.5':16, '3': 16})
+ versions={'2.7':16, '2.6':16, '2.5':16, '3': 16})
def go():
return sess2.merge(p2, load=False)
p3 = go()
@profiling.function_call_count(variance=0.10,
versions={'2.5':1050, '2.6':1050,
- '2.6+cextension':1014,
+ '2.6+cextension':1014,
'2.7':1014,
'3':1050}
)
class LoadManyToOneFromIdentityTest(fixtures.MappedTest):
"""test overhead associated with many-to-one fetches.
- Prior to the refactor of LoadLazyAttribute and
+ Prior to the refactor of LoadLazyAttribute and
query._get(), the load from identity map took 2x
as many calls (65K calls here instead of around 33K)
to load 1000 related objects from the identity map.
"""
- # only need to test for unexpected variance in a large call
+ # only need to test for unexpected variance in a large call
# count here,
# so remove some platforms that have wildly divergent
# callcounts.
@classmethod
def define_tables(cls, metadata):
- parent = Table('parent', metadata,
- Column('id', Integer, primary_key=True),
+ parent = Table('parent', metadata,
+ Column('id', Integer, primary_key=True),
Column('data', String(20)),
Column('child_id', Integer, ForeignKey('child.id'))
)
- child = Table('child', metadata,
+ child = Table('child', metadata,
Column('id', Integer,primary_key=True),
Column('data', String(20))
)
])
parent.insert().execute([
{
- 'id':i,
- 'data':'p%dc%d' % (i, (i % 250) + 1),
+ 'id':i,
+ 'data':'p%dc%d' % (i, (i % 250) + 1),
'child_id':(i % 250) + 1
- }
+ }
for i in xrange(1, 1000)
])
@classmethod
def define_tables(cls, metadata):
Table('a', metadata,
- Column('id', Integer, primary_key=True),
+ Column('id', Integer, primary_key=True),
Column('c_id', Integer, ForeignKey('c.id'))
)
Table('b', metadata,
- Column('id', Integer, primary_key=True),
+ Column('id', Integer, primary_key=True),
Column('a_id', Integer, ForeignKey('a.id'))
)
Table('c', metadata,
- Column('id', Integer, primary_key=True),
+ Column('id', Integer, primary_key=True),
)
Table('d', metadata,
- Column('id', Integer, primary_key=True),
+ Column('id', Integer, primary_key=True),
Column('a_id', Integer, ForeignKey('a.id'))
)
cls.classes.C, cls.classes.D
s = Session()
s.add_all([
- A(id=i,
+ A(id=i,
bs=[B(id=(i * 50) + j) for j in xrange(1, 50)],
c=C(id=i),
ds=[D(id=(i * 50) + j) for j in xrange(1, 50)]
self.classes.C, self.classes.D
s = Session()
for a in [
- A(id=i,
+ A(id=i,
bs=[B(id=(i * 50) + j) for j in xrange(1, 50)],
c=C(id=i),
ds=[D(id=(i * 50) + j) for j in xrange(1, 50)]