Skip to content

Commit 0cb426d

Browse files
committed
feat: support Elasticsearch datasource #108
1 parent 2a1205d commit 0cb426d

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

backend/apps/datasource/api/datasource.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class TestObj(BaseModel):
135135
sql: str = None
136136

137137

138+
# not used, just do test
138139
@router.post("/execSql/{id}")
139140
async def exec_sql(session: SessionDep, id: int, obj: TestObj):
140141
def inner():

backend/apps/datasource/crud/datasource.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def preview(session: SessionDep, current_user: CurrentUser, id: int, data: Table
297297
sql = f"""SELECT "{'", "'.join(fields)}" FROM "{data.table.table_name}"
298298
{where}
299299
LIMIT 100"""
300-
return exec_sql(ds, sql, True)
300+
return exec_sql(ds, sql, True, [data.table.table_name])
301301

302302

303303
def fieldEnum(session: SessionDep, id: int):
@@ -313,7 +313,7 @@ def fieldEnum(session: SessionDep, id: int):
313313

314314
db = DB.get_db(ds.type)
315315
sql = f"""SELECT DISTINCT {db.prefix}{field.field_name}{db.suffix} FROM {db.prefix}{table.table_name}{db.suffix}"""
316-
res = exec_sql(ds, sql, True)
316+
res = exec_sql(ds, sql, True, [table.table_name])
317317
return [item.get(res.get('fields')[0]) for item in res.get('data')]
318318

319319

@@ -353,7 +353,7 @@ def get_table_schema(session: SessionDep, current_user: CurrentUser, ds: CoreDat
353353
db_name = table_objs[0].schema
354354
schema_str += f"【DB_ID】 {db_name}\n【Schema】\n"
355355
for obj in table_objs:
356-
schema_str += f"# Table: {db_name}.{obj.table.table_name}" if ds.type != "mysql" else f"# Table: {obj.table.table_name}"
356+
schema_str += f"# Table: {db_name}.{obj.table.table_name}" if ds.type != "mysql" and ds.type != "es" else f"# Table: {obj.table.table_name}"
357357
table_comment = ''
358358
if obj.table.custom_comment:
359359
table_comment = obj.table.custom_comment.strip()

0 commit comments

Comments
 (0)