MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _parse_column_info

Method _parse_column_info

lib/sqlalchemy/dialects/mssql/base.py:3544–3633  ·  view source on GitHub ↗
(
        self,
        name,
        type_,
        nullable,
        maxlen,
        numericprec,
        numericscale,
        default,
        collation,
        definition,
        is_persisted,
        is_identity,
        identity_start,
        identity_increment,
        comment,
        base_type=None,
    )

Source from the content-addressed store, hash-verified

3542 ) from ne
3543
3544 def _parse_column_info(
3545 self,
3546 name,
3547 type_,
3548 nullable,
3549 maxlen,
3550 numericprec,
3551 numericscale,
3552 default,
3553 collation,
3554 definition,
3555 is_persisted,
3556 is_identity,
3557 identity_start,
3558 identity_increment,
3559 comment,
3560 base_type=None,
3561 ):
3562 # Try to resolve the user type first (e.g., "sysname"),
3563 # then fall back to the base type (e.g., "nvarchar").
3564 # base_type may be None for CLR types (geography, geometry,
3565 # hierarchyid) which have no corresponding base type.
3566 coltype = self.ischema_names.get(type_, None)
3567 if coltype is None and base_type is not None and base_type != type_:
3568 coltype = self.ischema_names.get(base_type, None)
3569 kwargs = {}
3570
3571 if coltype in (MSBinary, MSVarBinary, sqltypes.LargeBinary):
3572 kwargs["length"] = maxlen if maxlen != -1 else None
3573 elif coltype in (MSString, MSChar, MSText):
3574 kwargs["length"] = maxlen if maxlen != -1 else None
3575 if collation:
3576 kwargs["collation"] = collation
3577 elif coltype in (MSNVarchar, MSNChar, MSNText):
3578 kwargs["length"] = maxlen // 2 if maxlen != -1 else None
3579 if collation:
3580 kwargs["collation"] = collation
3581
3582 if coltype is None:
3583 if base_type is not None and base_type != type_:
3584 util.warn(
3585 "Did not recognize type '%s' (user type) or '%s' "
3586 "(base type) of column '%s'" % (type_, base_type, name)
3587 )
3588 else:
3589 util.warn(
3590 "Did not recognize type '%s' of column '%s'"
3591 % (type_, name)
3592 )
3593 coltype = sqltypes.NULLTYPE
3594 else:
3595 if issubclass(coltype, sqltypes.NumericCommon):
3596 kwargs["precision"] = numericprec
3597 if not issubclass(coltype, sqltypes.Float):
3598 kwargs["scale"] = numericscale
3599 coltype = coltype(**kwargs)
3600
3601 cdict = {

Callers 1

_fetch_multi_columnsMethod · 0.95

Calls 2

getMethod · 0.45
warnMethod · 0.45

Tested by

no test coverage detected