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,
)
| 3280 | return self._schema_item_copy(fk) |
| 3281 | |
| 3282 | def _get_colspec( |
| 3283 | self, |
| 3284 | schema: Optional[ |
| 3285 | Union[ |
| 3286 | str, |
| 3287 | Literal[SchemaConst.RETAIN_SCHEMA, SchemaConst.BLANK_SCHEMA], |
| 3288 | ] |
| 3289 | ] = None, |
| 3290 | table_name: Optional[str] = None, |
| 3291 | _is_copy: bool = False, |
| 3292 | ) -> str: |
| 3293 | """Return a string based 'column specification' for this |
| 3294 | :class:`_schema.ForeignKey`. |
| 3295 | |
| 3296 | This is usually the equivalent of the string-based "tablename.colname" |
| 3297 | argument first passed to the object's constructor. |
| 3298 | |
| 3299 | """ |
| 3300 | |
| 3301 | _colspec, effective_table_column = self._resolve_colspec_argument() |
| 3302 | |
| 3303 | if schema not in (None, RETAIN_SCHEMA): |
| 3304 | _schema, tname, colname = self._column_tokens |
| 3305 | if table_name is not None: |
| 3306 | tname = table_name |
| 3307 | if schema is BLANK_SCHEMA: |
| 3308 | return "%s.%s" % (tname, colname) |
| 3309 | else: |
| 3310 | return "%s.%s.%s" % (schema, tname, colname) |
| 3311 | elif table_name: |
| 3312 | schema, tname, colname = self._column_tokens |
| 3313 | if schema: |
| 3314 | return "%s.%s.%s" % (schema, table_name, colname) |
| 3315 | else: |
| 3316 | return "%s.%s" % (table_name, colname) |
| 3317 | elif effective_table_column is not None: |
| 3318 | if effective_table_column.table is None: |
| 3319 | if _is_copy: |
| 3320 | raise exc.InvalidRequestError( |
| 3321 | f"Can't copy ForeignKey object which refers to " |
| 3322 | f"non-table bound Column {effective_table_column!r}" |
| 3323 | ) |
| 3324 | else: |
| 3325 | return effective_table_column.key |
| 3326 | return "%s.%s" % ( |
| 3327 | effective_table_column.table.fullname, |
| 3328 | effective_table_column.key, |
| 3329 | ) |
| 3330 | else: |
| 3331 | assert isinstance(_colspec, str) |
| 3332 | return _colspec |
| 3333 | |
| 3334 | @property |
| 3335 | def _referred_schema(self) -> Optional[str]: |