diff --git a/backend/apps/db/db.py b/backend/apps/db/db.py index 6549740b..fe85de6c 100644 --- a/backend/apps/db/db.py +++ b/backend/apps/db/db.py @@ -254,7 +254,7 @@ def get_schema(ds: CoreDatasource): def get_tables(ds: CoreDatasource): conf = DatasourceConf(**json.loads(aes_decrypt(ds.configuration))) if ds.type != "excel" else get_engine_config() db = DB.get_db(ds.type) - sql = get_table_sql(ds, conf) + sql = get_table_sql(ds, conf, get_version(ds)) if db.connect_type == ConnectType.sqlalchemy: with get_session(ds) as session: with session.execute(text(sql)) as result: diff --git a/backend/apps/db/db_sql.py b/backend/apps/db/db_sql.py index 34982f6f..10af38f8 100644 --- a/backend/apps/db/db_sql.py +++ b/backend/apps/db/db_sql.py @@ -32,7 +32,7 @@ def get_version_sql(ds: CoreDatasource, conf: DatasourceConf): return '' -def get_table_sql(ds: CoreDatasource, conf: DatasourceConf): +def get_table_sql(ds: CoreDatasource, conf: DatasourceConf, db_version: str = ''): if ds.type == "mysql" or ds.type == "doris": return f""" SELECT @@ -95,13 +95,23 @@ def get_table_sql(ds: CoreDatasource, conf: DatasourceConf): ORDER BY t.TABLE_NAME """ elif ds.type == "ck": - return f""" - SELECT name, comment - FROM system.tables - WHERE database = '{conf.database}' - AND engine NOT IN ('Dictionary') - ORDER BY name - """ + version = int(db_version.split('.')[0]) + if version < 22: + return f""" + SELECT name, null as comment + FROM system.tables + WHERE database = '{conf.database}' + AND engine NOT IN ('Dictionary') + ORDER BY name + """ + else: + return f""" + SELECT name, comment + FROM system.tables + WHERE database = '{conf.database}' + AND engine NOT IN ('Dictionary') + ORDER BY name + """ elif ds.type == 'dm': return f""" select table_name, comments