@@ -23,16 +23,29 @@ class SizeUnit(Enum):
23
23
class ColumnType :
24
24
name : str
25
25
precision : Optional [int ] = None
26
+ """For column types DECIMAL and INTEGER."""
26
27
scale : Optional [int ] = None
28
+ """For column types DECIMAL and INTEGER."""
27
29
size : Optional [int ] = None
30
+ """For column types CHAR and VARCHAR."""
28
31
characterSet : Optional [str ] = None
32
+ """For column types CHAR and VARCHAR. Supported values: "ASCII" and "UTF8"."""
29
33
withLocalTimeZone : Optional [bool ] = None
34
+ """Only for column type TIMESTAMP."""
30
35
fraction : Optional [int ] = None
36
+ """Number of fractional seconds for column type TIMESTAMP."""
31
37
srid : Optional [int ] = None
38
+ """Spatial reference system identifier, only for column type GEOMETRY."""
32
39
unit : Optional [SizeUnit ] = None
40
+ """Only for column type HASHTYPE. Supported values: "BYTE" and "BIT"."""
33
41
34
42
@property
35
43
def rendered (self ) -> str :
44
+ """
45
+ Return a string representing the type including all parameters
46
+ such as scale or precision appropriate for creating an SQL statement
47
+ CREATE TABLE.
48
+ """
36
49
name = self .name .upper ()
37
50
38
51
def args () -> Iterator [Any ]:
@@ -57,6 +70,8 @@ def elements() -> Iterator[str]:
57
70
yield f"({ infix } )"
58
71
if name == "VARCHAR" :
59
72
yield f' { self .characterSet or "UTF8" } '
73
+ if (name == "TIMESTAMP" ) and self .withLocalTimeZone :
74
+ yield " WITH LOCAL TIME ZONE"
60
75
61
76
return "" .join (elements ())
62
77
0 commit comments