MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _column_tokens

Method _column_tokens

lib/sqlalchemy/sql/schema.py:3375–3399  ·  view source on GitHub ↗

parse a string-based _colspec into its component parts.

(self)

Source from the content-addressed store, hash-verified

3373
3374 @util.memoized_property
3375 def _column_tokens(self) -> Tuple[Optional[str], str, Optional[str]]:
3376 """parse a string-based _colspec into its component parts."""
3377
3378 m = self._get_colspec().split(".")
3379 if len(m) == 1:
3380 tname = m.pop()
3381 colname = None
3382 else:
3383 colname = m.pop()
3384 tname = m.pop()
3385
3386 # A FK between column 'bar' and table 'foo' can be
3387 # specified as 'foo', 'foo.bar', 'dbo.foo.bar',
3388 # 'otherdb.dbo.foo.bar'. Once we have the column name and
3389 # the table name, treat everything else as the schema
3390 # name. Some databases (e.g. Sybase) support
3391 # inter-database foreign keys. See tickets#1341 and --
3392 # indirectly related -- Ticket #594. This assumes that '.'
3393 # will never appear *within* any component of the FK.
3394
3395 if len(m) > 0:
3396 schema = ".".join(m)
3397 else:
3398 schema = None
3399 return schema, tname, colname
3400
3401 def _resolve_col_tokens(self) -> Tuple[Table, str, Optional[str]]:
3402 if self.parent is None:

Callers

nothing calls this directly

Calls 4

_get_colspecMethod · 0.95
splitMethod · 0.80
popMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected