Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions backend/apps/datasource/api/datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ async def get_fields(session: SessionDep,


@router.post("/syncFields/{id}", response_model=None, summary=f"{PLACEHOLDER_PREFIX}ds_sync_fields")
async def sync_fields(session: SessionDep, id: int = Path(..., description=f"{PLACEHOLDER_PREFIX}ds_table_id")):
return sync_single_fields(session, id)
async def sync_fields(session: SessionDep, trans: Trans,
id: int = Path(..., description=f"{PLACEHOLDER_PREFIX}ds_table_id")):
return sync_single_fields(session, trans, id)


from pydantic import BaseModel
Expand Down
10 changes: 9 additions & 1 deletion backend/apps/datasource/crud/datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,18 @@ def execSql(session: SessionDep, id: int, sql: str):
return exec_sql(ds, sql, True)


def sync_single_fields(session: SessionDep, id: int):
def sync_single_fields(session: SessionDep, trans: Trans, id: int):
table = session.query(CoreTable).filter(CoreTable.id == id).first()
ds = session.query(CoreDatasource).filter(CoreDatasource.id == table.ds_id).first()

tables = getTablesByDs(session, ds)
t_name = []
for _t in tables:
t_name.append(_t.tableName)

if not table.table_name in t_name:
raise HTTPException(status_code=500, detail=trans('i18n_table_not_exist'))

# sync field
fields = getFieldsByDs(session, ds, table.table_name)
sync_fields(session, ds, table, fields)
Expand Down
3 changes: 2 additions & 1 deletion backend/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,6 @@
"params_setting": "Parameters Setting",
"rules": "Permission Rules",
"log_setting": "Login Authentication"
}
},
"i18n_table_not_exist": "Table not exist"
}
3 changes: 2 additions & 1 deletion backend/locales/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,6 @@
"params_setting": "매개변수 설정",
"rules": "권한 규칙",
"log_setting": "로그인 인증"
}
},
"i18n_table_not_exist": "현재 테이블이 존재하지 않습니다"
}
3 changes: 2 additions & 1 deletion backend/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,6 @@
"params_setting": "参数设置",
"rules": "权限规则",
"log_setting": "登录认证"
}
},
"i18n_table_not_exist": "当前表不存在"
}