Skip to content

Commit ebc63ed

Browse files
committed
feat: Support for batch uploading data table notes #557
1 parent c1393f3 commit ebc63ed

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

backend/apps/datasource/api/datasource.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,19 +418,21 @@ def inner():
418418
else:
419419
ds = session.query(CoreDatasource).filter(CoreDatasource.id == id).first()
420420
file_name = ds.name
421-
tables = session.query(CoreTable).filter(CoreTable.ds_id == id).all()
421+
tables = session.query(CoreTable).filter(CoreTable.ds_id == id).order_by(
422+
CoreTable.table_name.asc()).all()
422423
if len(tables) == 0:
423424
raise HTTPException(400, "No tables")
424425

425426
df_list = []
426-
df1 = {'sheet': t_sheet, 'c0_h': t_s_col,'c1_h': t_n_col, 'c2_h': t_c_col,'c0': [], 'c1': [], 'c2': []}
427+
df1 = {'sheet': t_sheet, 'c0_h': t_s_col, 'c1_h': t_n_col, 'c2_h': t_c_col, 'c0': [], 'c1': [], 'c2': []}
427428
df_list.append(df1)
428429
for index, table in enumerate(tables):
429430
df1['c0'].append(f"Sheet{index}")
430431
df1['c1'].append(table.table_name)
431432
df1['c2'].append(table.custom_comment)
432433

433-
fields = session.query(CoreField).filter(CoreField.table_id == table.id).all()
434+
fields = session.query(CoreField).filter(CoreField.table_id == table.id).order_by(
435+
CoreField.field_index.asc()).all()
434436
df_fields = {'sheet': f"Sheet{index}", 'c1_h': f_n_col, 'c2_h': f_c_col, 'c1': [], 'c2': []}
435437
for field in fields:
436438
df_fields['c1'].append(field.field_name)

0 commit comments

Comments
 (0)