Skip to content

Commit a5e57c1

Browse files
committed
feat: add thousands separator settings
1 parent ee5e80d commit a5e57c1

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

backend/apps/db/db.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,20 @@ def is_numeric_type_code(type_code, dialect_name: str) -> bool:
640640
type_str = str(type_code).upper()
641641
return any(kw in type_str for kw in ['NUMBER', 'FLOAT', 'INTEGER', 'BINARY_FLOAT', 'BINARY_DOUBLE'])
642642

643+
if dialect_name == 'clickhouse':
644+
if isinstance(type_code, str):
645+
upper_type = type_code.upper()
646+
# 数值类型关键字
647+
numeric_prefixes = (
648+
'INT', # Int8/16/32/64
649+
'UINT', # UInt8/16/32/64 ✅ 加上 UINT
650+
'FLOAT', # Float32, Float64
651+
'DECIMAL', # Decimal, Decimal32/64/128
652+
'BOOL', # Bool
653+
'BIT', # 极少数场景
654+
)
655+
return any(upper_type.startswith(p) for p in numeric_prefixes)
656+
643657
# ---------- SQL Server (pyodbc / pymssql) ----------
644658
if dialect_name == 'mssql':
645659
if isinstance(type_code, int):
@@ -841,7 +855,7 @@ def build_fields_info_from_cursor(cursor, origin_column, db_type='postgresql'):
841855
for col_info in cursor.description:
842856
col_name = col_info[0]
843857

844-
if db_type == 'mysql':
858+
if db_type in ('mysql', 'mariadb', 'doris', 'starrocks'):
845859
# MySQL/pymysql 类型码
846860
is_numeric = col_info[1] in (
847861
1, # TINYINT
@@ -852,24 +866,25 @@ def build_fields_info_from_cursor(cursor, origin_column, db_type='postgresql'):
852866
8, # BIGINT
853867
9, # MEDIUMINT
854868
16, # BIT
855-
246, # DECIMAL
869+
246, # DECIMAL/NEWDECIMAL
856870
)
857871
elif db_type in ('postgresql', 'redshift', 'kingbase'):
858872
# PostgreSQL/psycopg2 类型 OID
859873
is_numeric = col_info[1] in (
874+
16, # bool
860875
20, # int8
861876
21, # int2
862877
23, # int4
863878
700, # float4
864879
701, # float8
880+
790, # money
865881
1700, # numeric
866-
16, # boolean
867882
)
868883
elif db_type == 'dm':
869884
# 达梦数据库类型码
870885
is_numeric = col_info[1] in (
871-
3, # DECIMAL/NUMERIC
872886
2, # NUMBER
887+
3, # DECIMAL
873888
4, # INTEGER
874889
5, # INT
875890
6, # BIGINT

0 commit comments

Comments
 (0)