(row)
| 1486 | getter = result._getter(polymorphic_on) |
| 1487 | |
| 1488 | def polymorphic_instance(row): |
| 1489 | discriminator = getter(row) |
| 1490 | if discriminator is not None: |
| 1491 | _instance = polymorphic_instances[discriminator] |
| 1492 | if _instance: |
| 1493 | return _instance(row) |
| 1494 | elif _instance is False: |
| 1495 | identitykey = ensure_no_pk(row) |
| 1496 | |
| 1497 | if identitykey: |
| 1498 | raise sa_exc.InvalidRequestError( |
| 1499 | "Row with identity key %s can't be loaded into an " |
| 1500 | "object; the polymorphic discriminator column '%s' " |
| 1501 | "refers to %s, which is not a sub-mapper of " |
| 1502 | "the requested %s" |
| 1503 | % ( |
| 1504 | identitykey, |
| 1505 | polymorphic_on, |
| 1506 | mapper.polymorphic_map[discriminator], |
| 1507 | mapper, |
| 1508 | ) |
| 1509 | ) |
| 1510 | else: |
| 1511 | return None |
| 1512 | else: |
| 1513 | return instance_fn(row) |
| 1514 | else: |
| 1515 | identitykey = ensure_no_pk(row) |
| 1516 | |
| 1517 | if identitykey: |
| 1518 | raise sa_exc.InvalidRequestError( |
| 1519 | "Row with identity key %s can't be loaded into an " |
| 1520 | "object; the polymorphic discriminator column '%s' is " |
| 1521 | "NULL" % (identitykey, polymorphic_on) |
| 1522 | ) |
| 1523 | else: |
| 1524 | return None |
| 1525 | |
| 1526 | return polymorphic_instance |
| 1527 |
nothing calls this directly
no test coverage detected