From 8f251dded9f18cb03e171d714907aa0388bf7aed Mon Sep 17 00:00:00 2001 From: junjun Date: Thu, 25 Dec 2025 16:53:53 +0800 Subject: [PATCH] refactor: fields sort --- backend/apps/datasource/crud/datasource.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/apps/datasource/crud/datasource.py b/backend/apps/datasource/crud/datasource.py index 153e5088..37b7eeed 100644 --- a/backend/apps/datasource/crud/datasource.py +++ b/backend/apps/datasource/crud/datasource.py @@ -288,7 +288,8 @@ def preview(session: SessionDep, current_user: CurrentUser, id: int, data: Table if not data.table.id: return {"fields": [], "data": [], "sql": ''} - fields = session.query(CoreField).filter(CoreField.table_id == data.table.id).all() + fields = session.query(CoreField).filter(CoreField.table_id == data.table.id).order_by( + CoreField.field_index.asc()).all() if fields is None or len(fields) == 0: return {"fields": [], "data": [], "sql": ''}