Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix:mysql does not support 'returning' (#29069)

longbingljw4b969bdce398
diff --git a/api/controllers/service_api/wraps.py b/api/controllers/service_api/wraps.py
index c07e18c6863..cef85237227 100644
--- a/api/controllers/service_api/wraps.py
+++ b/api/controllers/service_api/wraps.py
@@ -316,19 +316,17 @@ def validate_and_get_api_token(scope: str | None = None):
ApiToken.type == scope,
)
.values(last_used_at=current_time)
- .returning(ApiToken)
)
+ stmt = select(ApiToken).where(ApiToken.token == auth_token, ApiToken.type == scope)
result = session.execute(update_stmt)
- api_token = result.scalar_one_or_none()
+ api_token = session.scalar(stmt)
- if not api_token:
- stmt = select(ApiToken).where(ApiToken.token == auth_token, ApiToken.type == scope)
- api_token = session.scalar(stmt)
- if not api_token:
- raise Unauthorized("Access token is invalid")
- else:
+ if hasattr(result, "rowcount") and result.rowcount > 0:
session.commit()
+ if not api_token:
+ raise Unauthorized("Access token is invalid")
+
return api_token