File tree 1 file changed +21
-1
lines changed
ydb_sqlalchemy/sqlalchemy/compiler
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
+
1
5
from .base import (
2
6
BaseYqlCompiler ,
3
7
BaseYqlDDLCompiler ,
7
11
8
12
9
13
class 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 )
11
31
12
32
13
33
class YqlIdentifierPreparer (BaseYqlIdentifierPreparer ):
You can’t perform that action at this time.
0 commit comments