Represent the SQL UUID type. This is the SQL-native form of the :class:`_types.Uuid` database agnostic datatype, and is backwards compatible with the previous PostgreSQL-only version of ``UUID``. The :class:`_sqltypes.UUID` datatype only works on databases that have a SQL datat
| 3970 | |
| 3971 | |
| 3972 | class UUID(Uuid[_UUID_RETURN], type_api.NativeForEmulated): |
| 3973 | """Represent the SQL UUID type. |
| 3974 | |
| 3975 | This is the SQL-native form of the :class:`_types.Uuid` database agnostic |
| 3976 | datatype, and is backwards compatible with the previous PostgreSQL-only |
| 3977 | version of ``UUID``. |
| 3978 | |
| 3979 | The :class:`_sqltypes.UUID` datatype only works on databases that have a |
| 3980 | SQL datatype named ``UUID``. It will not function for backends which don't |
| 3981 | have this exact-named type, including SQL Server. For backend-agnostic UUID |
| 3982 | values with native support, including for SQL Server's ``UNIQUEIDENTIFIER`` |
| 3983 | datatype, use the :class:`_sqltypes.Uuid` datatype. |
| 3984 | |
| 3985 | .. versionadded:: 2.0 |
| 3986 | |
| 3987 | .. seealso:: |
| 3988 | |
| 3989 | :class:`_sqltypes.Uuid` |
| 3990 | |
| 3991 | """ |
| 3992 | |
| 3993 | __visit_name__ = "UUID" |
| 3994 | |
| 3995 | @overload |
| 3996 | def __init__(self: UUID[_python_UUID], as_uuid: Literal[True] = ...): ... |
| 3997 | |
| 3998 | @overload |
| 3999 | def __init__(self: UUID[str], as_uuid: Literal[False] = ...): ... |
| 4000 | |
| 4001 | def __init__(self, as_uuid: bool = True): |
| 4002 | """Construct a :class:`_sqltypes.UUID` type. |
| 4003 | |
| 4004 | |
| 4005 | :param as_uuid=True: if True, values will be interpreted |
| 4006 | as Python uuid objects, converting to/from string via the |
| 4007 | DBAPI. |
| 4008 | |
| 4009 | .. versionchanged:: 2.0 ``as_uuid`` now defaults to ``True``. |
| 4010 | |
| 4011 | """ |
| 4012 | self.as_uuid = as_uuid |
| 4013 | self.native_uuid = True |
| 4014 | |
| 4015 | @classmethod |
| 4016 | def adapt_emulated_to_native(cls, impl, **kw): |
| 4017 | kw.setdefault("as_uuid", impl.as_uuid) |
| 4018 | return cls(**kw) |
| 4019 | |
| 4020 | |
| 4021 | NULLTYPE = NullType() |
no outgoing calls