MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / _verify_canload

Method _verify_canload

lib/sqlalchemy/orm/dependency.py:264–303  ·  view source on GitHub ↗
(self, state)

Source from the content-addressed store, hash-verified

262 )
263
264 def _verify_canload(self, state):
265 if self.prop.uselist and state is None:
266 raise exc.FlushError(
267 "Can't flush None value found in "
268 "collection %s" % (self.prop,)
269 )
270 elif state is not None and not self.mapper._canload(
271 state, allow_subtypes=not self.enable_typechecks
272 ):
273 if self.mapper._canload(state, allow_subtypes=True):
274 raise exc.FlushError(
275 "Attempting to flush an item of type "
276 "%(x)s as a member of collection "
277 '"%(y)s". Expected an object of type '
278 "%(z)s or a polymorphic subclass of "
279 "this type. If %(x)s is a subclass of "
280 '%(z)s, configure mapper "%(zm)s" to '
281 "load this subtype polymorphically, or "
282 "set enable_typechecks=False to allow "
283 "any subtype to be accepted for flush. "
284 % {
285 "x": state.class_,
286 "y": self.prop,
287 "z": self.mapper.class_,
288 "zm": self.mapper,
289 }
290 )
291 else:
292 raise exc.FlushError(
293 "Attempting to flush an item of type "
294 "%(x)s as a member of collection "
295 '"%(y)s". Expected an object of type '
296 "%(z)s or a polymorphic subclass of "
297 "this type."
298 % {
299 "x": state.class_,
300 "y": self.prop,
301 "z": self.mapper.class_,
302 }
303 )
304
305 def _synchronize(self, state, child, associationrow, clearkeys, uowcommit):
306 raise NotImplementedError()

Callers 3

_synchronizeMethod · 0.80
_synchronizeMethod · 0.80
_synchronizeMethod · 0.80

Calls 1

_canloadMethod · 0.80

Tested by

no test coverage detected