fixed up some of the error messages tailored
in [ticket:2069]
+ - 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
- Added explicit check for when Column .name
is assigned as blank string [ticket:2140]
)
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'):
+ raise sa_exc.InvalidRequestError(
+ "%s() can only be used against "
+ "a single mapped class." % methname)
+ return entity.entity_zero
+
def _only_entity_zero(self, rationale=None):
if len(self._entities) > 1:
raise sa_exc.InvalidRequestError(
ident = util.to_list(ident)
- mapper = self._only_mapper_zero(
- "get() can only be used against a single mapped class."
- )
+ mapper = self._only_full_mapper_zero("get")
if len(ident) != len(mapper.primary_key):
raise sa_exc.InvalidRequestError(
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(
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.InvalidRequestError, 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()."""