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

Method _verify_canload

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

Source from the content-addressed store, hash-verified

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

Callers 3

_synchronizeMethod · 0.80
_synchronizeMethod · 0.80
_synchronizeMethod · 0.80

Calls 1

_canloadMethod · 0.80

Tested by

no test coverage detected