File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
ydb_sqlalchemy/sqlalchemy/compiler Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 1+ from typing import Union
2+ import sqlalchemy as sa
3+ import ydb
4+
15from .base import (
26 BaseYqlCompiler ,
37 BaseYqlDDLCompiler ,
711
812
913class YqlTypeCompiler (BaseYqlTypeCompiler ):
10- ...
14+ # We use YDB Double for sa.Float for compatibility with old dialect version
15+ def visit_FLOAT (self , type_ : sa .FLOAT , ** kw ):
16+ return "DOUBLE"
17+
18+ def get_ydb_type (
19+ self , type_ : sa .types .TypeEngine , is_optional : bool
20+ ) -> Union [ydb .PrimitiveType , ydb .AbstractTypeBuilder ]:
21+ if isinstance (type_ , sa .TypeDecorator ):
22+ type_ = type_ .impl
23+
24+ if isinstance (type_ , sa .Float ):
25+ ydb_type = ydb .PrimitiveType .Double
26+ if is_optional :
27+ return ydb .OptionalType (ydb_type )
28+ return ydb_type
29+
30+ return super ().get_ydb_type (type_ , is_optional )
1131
1232
1333class YqlIdentifierPreparer (BaseYqlIdentifierPreparer ):
You can’t perform that action at this time.
0 commit comments