Skip to content

Commit ce4c305

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 8356bba + d77d153 commit ce4c305

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

backend/apps/datasource/crud/datasource.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def preview(session: SessionDep, current_user: CurrentUser, id: int, data: Table
246246
if data.fields is None or len(data.fields) == 0:
247247
return {"fields": [], "data": [], "sql": ''}
248248

249-
where = None
249+
where = ''
250250
f_list = [f for f in data.fields if f.checked]
251251
if is_normal_user(current_user):
252252
# column is checked, and, column permission for data.fields
@@ -294,7 +294,7 @@ def preview(session: SessionDep, current_user: CurrentUser, id: int, data: Table
294294
elif ds.type == "sqlServer":
295295
sql = f"""SELECT [{"], [".join(fields)}] FROM [{conf.dbSchema}].[{data.table.table_name}]
296296
{where}
297-
ORDER BY [{data.fields[0].field_name}]
297+
ORDER BY [{fields[0]}]
298298
OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY"""
299299
elif ds.type == "pg" or ds.type == "excel":
300300
sql = f"""SELECT "{'", "'.join(fields)}" FROM "{conf.dbSchema}"."{data.table.table_name}"
@@ -303,7 +303,7 @@ def preview(session: SessionDep, current_user: CurrentUser, id: int, data: Table
303303
elif ds.type == "oracle":
304304
sql = f"""SELECT "{'", "'.join(fields)}" FROM "{conf.dbSchema}"."{data.table.table_name}"
305305
{where}
306-
ORDER BY "{data.fields[0].field_name}"
306+
ORDER BY "{fields[0]}"
307307
OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY"""
308308
return exec_sql(ds, sql)
309309

0 commit comments

Comments
 (0)