@@ -186,20 +186,21 @@ def querystring(self) -> QueryString:
186186
187187
188188@dataclass
189- class SetPrecision (AlterColumnStatement ):
189+ class SetDigits (AlterColumnStatement ):
190190
191- __slots__ = ("precision" , "scale " , "column_type" )
191+ __slots__ = ("digits " , "column_type" )
192192
193- precision : t .Optional [int ]
194- scale : t .Optional [int ]
193+ digits : t .Optional [t .Tuple [int , int ]]
195194 column_type : str
196195
197196 @property
198197 def querystring (self ) -> QueryString :
199- if self .precision and self .scale :
198+ if self .digits is not None :
199+ precision = self .digits [0 ]
200+ scale = self .digits [1 ]
200201 return QueryString (
201202 f"ALTER COLUMN { self .column_name } TYPE "
202- f"{ self .column_type } ({ self . precision } , { self . scale } )"
203+ f"{ self .column_type } ({ precision } , { scale } )"
203204 )
204205 else :
205206 return QueryString (
@@ -220,7 +221,7 @@ class Alter(Query):
220221 "_rename_table" ,
221222 "_set_length" ,
222223 "_unique" ,
223- "_set_precision " ,
224+ "_set_digits " ,
224225 )
225226
226227 def __init__ (self , table : t .Type [Table ]):
@@ -235,7 +236,7 @@ def __init__(self, table: t.Type[Table]):
235236 self ._rename_table : t .List [RenameTable ] = []
236237 self ._set_length : t .List [SetLength ] = []
237238 self ._unique : t .List [Unique ] = []
238- self ._set_precision : t .List [SetPrecision ] = []
239+ self ._set_digits : t .List [SetDigits ] = []
239240
240241 def add_column (self , name : str , column : Column ) -> Alter :
241242 """
@@ -374,24 +375,18 @@ def add_foreign_key_constraint(
374375 )
375376 return self
376377
377- def set_precision (
378+ def set_digits (
378379 self ,
379380 column : t .Union [str , Numeric ],
380- precision : t .Optional [int ],
381- scale : t .Optional [int ],
381+ digits : t .Optional [t .Tuple [int , int ]],
382382 ):
383383 column_type = (
384384 column .__class__ .__name__ .upper ()
385385 if isinstance (column , Numeric )
386386 else "NUMERIC"
387387 )
388- self ._set_precision .append (
389- SetPrecision (
390- precision = precision ,
391- scale = scale ,
392- column = column ,
393- column_type = column_type ,
394- )
388+ self ._set_digits .append (
389+ SetDigits (digits = digits , column = column , column_type = column_type ,)
395390 )
396391 return self
397392
@@ -459,7 +454,7 @@ def querystrings(self) -> t.Sequence[QueryString]:
459454 self ._unique ,
460455 self ._null ,
461456 self ._set_length ,
462- self ._set_precision ,
457+ self ._set_digits ,
463458 )
464459 ]
465460
0 commit comments