Return a string based 'column specification' for this :class:`_schema.ForeignKey`. This is usually the equivalent of the string-based "tablename.colname" argument first passed to the object's constructor.
(
self,
schema: Optional[
Union[
str,
Literal[SchemaConst.RETAIN_SCHEMA, SchemaConst.BLANK_SCHEMA],
]
] = None,
table_name: Optional[str] = None,
_is_copy: bool = False,
)
| 2978 | return self._schema_item_copy(fk) |
| 2979 | |
| 2980 | def _get_colspec( |
| 2981 | self, |
| 2982 | schema: Optional[ |
| 2983 | Union[ |
| 2984 | str, |
| 2985 | Literal[SchemaConst.RETAIN_SCHEMA, SchemaConst.BLANK_SCHEMA], |
| 2986 | ] |
| 2987 | ] = None, |
| 2988 | table_name: Optional[str] = None, |
| 2989 | _is_copy: bool = False, |
| 2990 | ) -> str: |
| 2991 | """Return a string based 'column specification' for this |
| 2992 | :class:`_schema.ForeignKey`. |
| 2993 | |
| 2994 | This is usually the equivalent of the string-based "tablename.colname" |
| 2995 | argument first passed to the object's constructor. |
| 2996 | |
| 2997 | """ |
| 2998 | if schema not in (None, RETAIN_SCHEMA): |
| 2999 | _schema, tname, colname = self._column_tokens |
| 3000 | if table_name is not None: |
| 3001 | tname = table_name |
| 3002 | if schema is BLANK_SCHEMA: |
| 3003 | return "%s.%s" % (tname, colname) |
| 3004 | else: |
| 3005 | return "%s.%s.%s" % (schema, tname, colname) |
| 3006 | elif table_name: |
| 3007 | schema, tname, colname = self._column_tokens |
| 3008 | if schema: |
| 3009 | return "%s.%s.%s" % (schema, table_name, colname) |
| 3010 | else: |
| 3011 | return "%s.%s" % (table_name, colname) |
| 3012 | elif self._table_column is not None: |
| 3013 | if self._table_column.table is None: |
| 3014 | if _is_copy: |
| 3015 | raise exc.InvalidRequestError( |
| 3016 | f"Can't copy ForeignKey object which refers to " |
| 3017 | f"non-table bound Column {self._table_column!r}" |
| 3018 | ) |
| 3019 | else: |
| 3020 | return self._table_column.key |
| 3021 | return "%s.%s" % ( |
| 3022 | self._table_column.table.fullname, |
| 3023 | self._table_column.key, |
| 3024 | ) |
| 3025 | else: |
| 3026 | assert isinstance(self._colspec, str) |
| 3027 | return self._colspec |
| 3028 | |
| 3029 | @property |
| 3030 | def _referred_schema(self) -> Optional[str]: |
no outgoing calls