(self)
| 1510 | return expr |
| 1511 | |
| 1512 | def _configure_pks(self) -> None: |
| 1513 | self.tables = sql_util.find_tables(self.persist_selectable) |
| 1514 | |
| 1515 | self._all_tables.update(t for t in self.tables) |
| 1516 | |
| 1517 | self._pks_by_table = {} |
| 1518 | self._cols_by_table = {} |
| 1519 | |
| 1520 | all_cols = util.column_set( |
| 1521 | chain(*[col.proxy_set for col in self._columntoproperty]) |
| 1522 | ) |
| 1523 | |
| 1524 | pk_cols = util.column_set(c for c in all_cols if c.primary_key) |
| 1525 | |
| 1526 | # identify primary key columns which are also mapped by this mapper. |
| 1527 | for fc in set(self.tables).union([self.persist_selectable]): |
| 1528 | if fc.primary_key and pk_cols.issuperset(fc.primary_key): |
| 1529 | # ordering is important since it determines the ordering of |
| 1530 | # mapper.primary_key (and therefore query.get()) |
| 1531 | self._pks_by_table[fc] = util.ordered_column_set( # type: ignore # noqa: E501 |
| 1532 | fc.primary_key |
| 1533 | ).intersection( |
| 1534 | pk_cols |
| 1535 | ) |
| 1536 | self._cols_by_table[fc] = util.ordered_column_set(fc.c).intersection( # type: ignore # noqa: E501 |
| 1537 | all_cols |
| 1538 | ) |
| 1539 | |
| 1540 | if self._primary_key_argument: |
| 1541 | coerced_pk_arg = [ |
| 1542 | ( |
| 1543 | self._str_arg_to_mapped_col("primary_key", c) |
| 1544 | if isinstance(c, str) |
| 1545 | else c |
| 1546 | ) |
| 1547 | for c in ( |
| 1548 | coercions.expect( |
| 1549 | roles.DDLConstraintColumnRole, |
| 1550 | coerce_pk, |
| 1551 | argname="primary_key", |
| 1552 | ) |
| 1553 | for coerce_pk in self._primary_key_argument |
| 1554 | ) |
| 1555 | ] |
| 1556 | else: |
| 1557 | coerced_pk_arg = None |
| 1558 | |
| 1559 | # if explicit PK argument sent, add those columns to the |
| 1560 | # primary key mappings |
| 1561 | if coerced_pk_arg: |
| 1562 | for k in coerced_pk_arg: |
| 1563 | if k.table not in self._pks_by_table: |
| 1564 | self._pks_by_table[k.table] = util.OrderedSet() |
| 1565 | self._pks_by_table[k.table].add(k) |
| 1566 | |
| 1567 | # otherwise, see that we got a full PK for the mapped table |
| 1568 | elif ( |
| 1569 | self.persist_selectable not in self._pks_by_table |
no test coverage detected