invalid, this condition now raises a deprecation warning.
[ticket:2144]
=======
CHANGES
=======
+0.6.8
+=====
+- orm
+ - Calling query.get() against a column-based entity is
+ invalid, this condition now raises a deprecation warning.
+ [ticket:2144]
+
0.6.7
=====
- orm
inside to the outside query if from_self()
were used. [ticket:2130].
+ - It is an error to call query.get() when the
+ given entity is not a single, full class
+ entity or mapper (i.e. a column). This is
+ a deprecation warning in 0.6.8.
+ [ticket:2144]
+
- sql
- Column.copy(), as used in table.tometadata(), copies the
'doc' attribute. [ticket:2028]
__all__ = sorted(name for name, obj in locals().items()
if not (name.startswith('_') or inspect.ismodule(obj)))
-__version__ = '0.6.7'
+__version__ = '0.6.8'
del inspect, sys
)
return self._mapper_zero()
+ def _only_full_mapper_zero(self, methname):
+ if len(self._entities) != 1:
+ raise sa_exc.InvalidRequestError(
+ "%s() can only be used against "
+ "a single mapped class." % methname)
+ entity = self._entity_zero()
+ if not hasattr(entity, 'primary_entity'):
+ util.warn("Calling %s() with a "
+ "column-based entity is deprecated." %
+ methname)
+ return entity.entity_zero
+
def _only_entity_zero(self, rationale=None):
if len(self._entities) > 1:
raise sa_exc.InvalidRequestError(
if hasattr(ident, '__composite_values__'):
ident = ident.__composite_values__()
- key = self._only_mapper_zero(
- "get() can only be used against a single mapped class."
+ key = self._only_full_mapper_zero("get"
).identity_key_from_primary_key(ident)
return self._get(key, ident)
if colparams or not supports_default_values:
text += " (%s)" % ', '.join([preparer.format_column(c[0])
for c in colparams])
-
+
if self.returning or insert_stmt._returning:
self.returning = self.returning or insert_stmt._returning
returning_clause = self.returning_clause(insert_stmt, self.returning)
q = s.query(CompositePk)
assert_raises(sa_exc.InvalidRequestError, q.get, (7, 10, 100))
+ def test_get_against_col(self):
+ User = self.classes.User
+
+ s = Session()
+ q = s.query(User.id)
+ assert_raises(sa_exc.SAWarning, q.get, (5, ))
+
def test_get_null_pk(self):
"""test that a mapping which can have None in a
PK (i.e. map to an outerjoin) works with get()."""