11from __future__ import annotations
22
3- import warnings
43from datetime import datetime
5- from functools import partial
64from zoneinfo import ZoneInfo
75
86import sqlalchemy .types as types
9- from sqlalchemy import Column as RawColumn
107from sqlalchemy import DateTime , Enum
118from sqlalchemy .orm import mapped_column
129from typing_extensions import Annotated
1310
1411from .functions import utcnow
1512
16-
17- def _deprecated (name : str , replacement : str ):
18- warnings .warn (
19- f"{ name } is deprecated and will be removed in a future major release. "
20- f"Use { replacement } instead." ,
21- DeprecationWarning ,
22- stacklevel = 3 ,
23- )
24-
25-
26- _Column : partial [RawColumn ] = partial (RawColumn , nullable = False )
27-
28-
29- def Column (* args , ** kwargs ): # noqa: N802
30- _deprecated ("Column" , "Mapped[...] + mapped_column(...)" )
31- return _Column (* args , ** kwargs )
32-
33-
34- _NullColumn : partial [RawColumn ] = partial (RawColumn , nullable = True )
35-
36-
37- def NullColumn (* args , ** kwargs ): # noqa: N802
38- _deprecated ("NullColumn" , "Mapped[Optional[...]] + mapped_column(...)" )
39- return _NullColumn (* args , ** kwargs )
40-
41-
42- _DateNowColumn = partial (Column , type_ = DateTime (timezone = True ), server_default = utcnow ())
43-
44-
45- def DateNowColumn (* args , ** kwargs ): # noqa: N802
46- _deprecated ("DateNowColumn" , "Mapped[datetime_now] + mapped_column(...)" )
47- return _DateNowColumn (* args , ** kwargs )
48-
49-
5013# Module-level constants for default timezone values
5114_DEFAULT_UTC = ZoneInfo ("UTC" )
5215
@@ -62,11 +25,6 @@ def DateNowColumn(*args, **kwargs): # noqa: N802
6225str1024 = Annotated [str , 1024 ]
6326
6427
65- def EnumColumn (name , enum_type , ** kwargs ): # noqa: N802
66- _deprecated ("EnumColumn" , "Mapped[...] + enum_column(...)" )
67- return Column (name , Enum (enum_type , native_enum = False , length = 16 ), ** kwargs )
68-
69-
7028def enum_column (name , enum_type , ** kwargs ):
7129 return mapped_column (name , Enum (enum_type , native_enum = False , length = 16 ), ** kwargs )
7230
0 commit comments