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.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor(sqlalchemy_workflow_execution_repository): Use the max funtion for getting next_sequence_number. (#20966)
-LAN-c05e47ebc001
diff --git a/api/core/repositories/sqlalchemy_workflow_execution_repository.py b/api/core/repositories/sqlalchemy_workflow_execution_repository.pyindex 19086cffff1..e5ead9dc569 100644--- a/api/core/repositories/sqlalchemy_workflow_execution_repository.py+++ b/api/core/repositories/sqlalchemy_workflow_execution_repository.py@@ -6,7 +6,7 @@ import jsonimport loggingfrom typing import Optional, Union-from sqlalchemy import select+from sqlalchemy import func, selectfrom sqlalchemy.engine import Enginefrom sqlalchemy.orm import sessionmaker@@ -151,11 +151,11 @@ class SQLAlchemyWorkflowExecutionRepository(WorkflowExecutionRepository):existing = session.scalar(select(WorkflowRun).where(WorkflowRun.id == domain_model.id_))if not existing:# For new records, get the next sequence number- stmt = select(WorkflowRun.sequence_number).where(+ stmt = select(func.max(WorkflowRun.sequence_number)).where(WorkflowRun.app_id == self._app_id,WorkflowRun.tenant_id == self._tenant_id,)- max_sequence = session.scalar(stmt.order_by(WorkflowRun.sequence_number.desc()))+ max_sequence = session.scalar(stmt)db_model.sequence_number = (max_sequence or 0) + 1else:# For updates, keep the existing sequence number