File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -132,14 +132,24 @@ def get_simple_ds_list(self):
132132 def get_db_schema (self , ds_id : int ) -> str :
133133 ds = self .get_ds (ds_id )
134134 schema_str = ""
135- db_name = ds .db_schema
135+ #db_name = ds.db_schema
136+ db_name = ds .db_schema if ds .db_schema is not None and ds .db_schema != "" else ds .dataBase
136137 schema_str += f"【DB_ID】 { db_name } \n 【Schema】\n "
137138 for table in ds .tables :
138- schema_str += f"# Table: { db_name } .{ table .name } "
139- schema_str += f", { table .comment } \n [\n "
139+ schema_str += f"# Table: { db_name } .{ table .name } " if ds .type != "mysql" else f"# Table: { table .name } "
140+ table_comment = table .comment
141+ if table_comment == '' :
142+ schema_str += '\n [\n '
143+ else :
144+ schema_str += f", { table_comment } \n [\n "
145+
140146 field_list = []
141147 for field in table .fields :
142- field_list .append (f"({ field .name } :{ field .type } , { field .comment } )" )
148+ field_comment = field .comment
149+ if field_comment == '' :
150+ field_list .append (f"({ field .name } :{ field .type } )" )
151+ else :
152+ field_list .append (f"({ field .name } :{ field .type } , { field_comment } )" )
143153 schema_str += ",\n " .join (field_list )
144154 schema_str += '\n ]\n '
145155 return schema_str
Original file line number Diff line number Diff line change @@ -76,7 +76,9 @@ def extract_nested_json(text):
7676
7777def string_to_numeric_hash (text : str , bits : Optional [int ] = 64 ) -> int :
7878 hash_bytes = hashlib .sha256 (text .encode ()).digest ()
79- return int .from_bytes (hash_bytes [:bits // 8 ], byteorder = 'big' )
79+ hash_num = int .from_bytes (hash_bytes , byteorder = 'big' )
80+ max_bigint = 2 ** 63 - 1
81+ return hash_num % max_bigint
8082
8183
8284def setup_logging ():
You can’t perform that action at this time.
0 commit comments