MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / CHAR

Class CHAR

lib/sqlalchemy/dialects/mysql/types.py:737–775  ·  view source on GitHub ↗

MySQL CHAR type, for fixed-length character data.

Source from the content-addressed store, hash-verified

735
736
737class CHAR(_StringType, sqltypes.CHAR):
738 """MySQL CHAR type, for fixed-length character data."""
739
740 __visit_name__ = "CHAR"
741
742 def __init__(self, length: Optional[int] = None, **kwargs: Any):
743 """Construct a CHAR.
744
745 :param length: Maximum data length, in characters.
746
747 :param binary: Optional, use the default binary collation for the
748 national character set. This does not affect the type of data
749 stored, use a BINARY type for binary data.
750
751 :param collation: Optional, request a particular collation. Must be
752 compatible with the national character set.
753
754 """
755 super().__init__(length=length, **kwargs)
756
757 @classmethod
758 def _adapt_string_for_cast(cls, type_: sqltypes.String) -> sqltypes.CHAR:
759 # copy the given string type into a CHAR
760 # for the purposes of rendering a CAST expression
761 type_ = sqltypes.to_instance(type_)
762 if isinstance(type_, sqltypes.CHAR):
763 return type_
764 elif isinstance(type_, _StringType):
765 return CHAR(
766 length=type_.length,
767 charset=type_.charset,
768 collation=type_.collation,
769 ascii=type_.ascii,
770 binary=type_.binary,
771 unicode=type_.unicode,
772 national=False, # not supported in CAST
773 )
774 else:
775 return CHAR(length=type_.length)
776
777
778class NVARCHAR(_StringType, sqltypes.NVARCHAR):

Callers 2

dictionary.pyFile · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected