mirror of
https://gitee.com/dify_ai/dify.git
synced 2024-11-30 10:18:13 +08:00
chore: fix legacy API usages of Query.get() by Session.get() in SqlAlchemy 2 (#6340)
This commit is contained in:
parent
7c397f5722
commit
7943f7f697
@ -75,7 +75,7 @@ class DatasetDocumentSegmentListApi(Resource):
|
||||
)
|
||||
|
||||
if last_id is not None:
|
||||
last_segment = DocumentSegment.query.get(str(last_id))
|
||||
last_segment = db.session.get(DocumentSegment, str(last_id))
|
||||
if last_segment:
|
||||
query = query.filter(
|
||||
DocumentSegment.position > last_segment.position)
|
||||
|
@ -117,7 +117,7 @@ class MemberUpdateRoleApi(Resource):
|
||||
if not TenantAccountRole.is_valid_role(new_role):
|
||||
return {'code': 'invalid-role', 'message': 'Invalid role'}, 400
|
||||
|
||||
member = Account.query.get(str(member_id))
|
||||
member = db.session.get(Account, str(member_id))
|
||||
if not member:
|
||||
abort(404)
|
||||
|
||||
|
@ -68,7 +68,7 @@ class Dataset(db.Model):
|
||||
|
||||
@property
|
||||
def created_by_account(self):
|
||||
return Account.query.get(self.created_by)
|
||||
return db.session.get(Account, self.created_by)
|
||||
|
||||
@property
|
||||
def latest_process_rule(self):
|
||||
@ -336,7 +336,7 @@ class Document(db.Model):
|
||||
@property
|
||||
def dataset_process_rule(self):
|
||||
if self.dataset_process_rule_id:
|
||||
return DatasetProcessRule.query.get(self.dataset_process_rule_id)
|
||||
return db.session.get(DatasetProcessRule, self.dataset_process_rule_id)
|
||||
return None
|
||||
|
||||
@property
|
||||
@ -560,7 +560,7 @@ class AppDatasetJoin(db.Model):
|
||||
|
||||
@property
|
||||
def app(self):
|
||||
return App.query.get(self.app_id)
|
||||
return db.session.get(App, self.app_id)
|
||||
|
||||
|
||||
class DatasetQuery(db.Model):
|
||||
|
@ -115,11 +115,11 @@ class Workflow(db.Model):
|
||||
|
||||
@property
|
||||
def created_by_account(self):
|
||||
return Account.query.get(self.created_by)
|
||||
return db.session.get(Account, self.created_by)
|
||||
|
||||
@property
|
||||
def updated_by_account(self):
|
||||
return Account.query.get(self.updated_by) if self.updated_by else None
|
||||
return db.session.get(Account, self.updated_by) if self.updated_by else None
|
||||
|
||||
@property
|
||||
def graph_dict(self):
|
||||
@ -290,14 +290,14 @@ class WorkflowRun(db.Model):
|
||||
@property
|
||||
def created_by_account(self):
|
||||
created_by_role = CreatedByRole.value_of(self.created_by_role)
|
||||
return Account.query.get(self.created_by) \
|
||||
return db.session.get(Account, self.created_by) \
|
||||
if created_by_role == CreatedByRole.ACCOUNT else None
|
||||
|
||||
@property
|
||||
def created_by_end_user(self):
|
||||
from models.model import EndUser
|
||||
created_by_role = CreatedByRole.value_of(self.created_by_role)
|
||||
return EndUser.query.get(self.created_by) \
|
||||
return db.session.get(EndUser, self.created_by) \
|
||||
if created_by_role == CreatedByRole.END_USER else None
|
||||
|
||||
@property
|
||||
@ -500,14 +500,14 @@ class WorkflowNodeExecution(db.Model):
|
||||
@property
|
||||
def created_by_account(self):
|
||||
created_by_role = CreatedByRole.value_of(self.created_by_role)
|
||||
return Account.query.get(self.created_by) \
|
||||
return db.session.get(Account, self.created_by) \
|
||||
if created_by_role == CreatedByRole.ACCOUNT else None
|
||||
|
||||
@property
|
||||
def created_by_end_user(self):
|
||||
from models.model import EndUser
|
||||
created_by_role = CreatedByRole.value_of(self.created_by_role)
|
||||
return EndUser.query.get(self.created_by) \
|
||||
return db.session.get(EndUser, self.created_by) \
|
||||
if created_by_role == CreatedByRole.END_USER else None
|
||||
|
||||
@property
|
||||
@ -612,17 +612,17 @@ class WorkflowAppLog(db.Model):
|
||||
|
||||
@property
|
||||
def workflow_run(self):
|
||||
return WorkflowRun.query.get(self.workflow_run_id)
|
||||
return db.session.get(WorkflowRun, self.workflow_run_id)
|
||||
|
||||
@property
|
||||
def created_by_account(self):
|
||||
created_by_role = CreatedByRole.value_of(self.created_by_role)
|
||||
return Account.query.get(self.created_by) \
|
||||
return db.session.get(Account, self.created_by) \
|
||||
if created_by_role == CreatedByRole.ACCOUNT else None
|
||||
|
||||
@property
|
||||
def created_by_end_user(self):
|
||||
from models.model import EndUser
|
||||
created_by_role = CreatedByRole.value_of(self.created_by_role)
|
||||
return EndUser.query.get(self.created_by) \
|
||||
return db.session.get(EndUser, self.created_by) \
|
||||
if created_by_role == CreatedByRole.END_USER else None
|
||||
|
26
api/poetry.lock
generated
26
api/poetry.lock
generated
@ -2486,18 +2486,18 @@ docs = ["sphinx"]
|
||||
|
||||
[[package]]
|
||||
name = "flask-sqlalchemy"
|
||||
version = "3.0.5"
|
||||
version = "3.1.1"
|
||||
description = "Add SQLAlchemy support to your Flask application."
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "flask_sqlalchemy-3.0.5-py3-none-any.whl", hash = "sha256:cabb6600ddd819a9f859f36515bb1bd8e7dbf30206cc679d2b081dff9e383283"},
|
||||
{file = "flask_sqlalchemy-3.0.5.tar.gz", hash = "sha256:c5765e58ca145401b52106c0f46178569243c5da25556be2c231ecc60867c5b1"},
|
||||
{file = "flask_sqlalchemy-3.1.1-py3-none-any.whl", hash = "sha256:4ba4be7f419dc72f4efd8802d69974803c37259dd42f3913b0dcf75c9447e0a0"},
|
||||
{file = "flask_sqlalchemy-3.1.1.tar.gz", hash = "sha256:e4b68bb881802dda1a7d878b2fc84c06d1ee57fb40b874d3dc97dabfa36b8312"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
flask = ">=2.2.5"
|
||||
sqlalchemy = ">=1.4.18"
|
||||
sqlalchemy = ">=2.0.16"
|
||||
|
||||
[[package]]
|
||||
name = "flatbuffers"
|
||||
@ -2794,8 +2794,8 @@ files = [
|
||||
[package.dependencies]
|
||||
cffi = {version = ">=1.12.2", markers = "platform_python_implementation == \"CPython\" and sys_platform == \"win32\""}
|
||||
greenlet = [
|
||||
{version = ">=3.0rc3", markers = "platform_python_implementation == \"CPython\" and python_version >= \"3.11\""},
|
||||
{version = ">=2.0.0", markers = "platform_python_implementation == \"CPython\" and python_version < \"3.11\""},
|
||||
{version = ">=3.0rc3", markers = "platform_python_implementation == \"CPython\" and python_version >= \"3.11\""},
|
||||
]
|
||||
"zope.event" = "*"
|
||||
"zope.interface" = "*"
|
||||
@ -2899,12 +2899,12 @@ files = [
|
||||
google-auth = ">=2.14.1,<3.0.dev0"
|
||||
googleapis-common-protos = ">=1.56.2,<2.0.dev0"
|
||||
grpcio = [
|
||||
{version = ">=1.49.1,<2.0dev", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""},
|
||||
{version = ">=1.33.2,<2.0dev", optional = true, markers = "python_version < \"3.11\" and extra == \"grpc\""},
|
||||
{version = ">=1.49.1,<2.0dev", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""},
|
||||
]
|
||||
grpcio-status = [
|
||||
{version = ">=1.49.1,<2.0.dev0", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""},
|
||||
{version = ">=1.33.2,<2.0.dev0", optional = true, markers = "python_version < \"3.11\" and extra == \"grpc\""},
|
||||
{version = ">=1.49.1,<2.0.dev0", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""},
|
||||
]
|
||||
proto-plus = ">=1.22.3,<2.0.0dev"
|
||||
protobuf = ">=3.19.5,<3.20.0 || >3.20.0,<3.20.1 || >3.20.1,<4.21.0 || >4.21.0,<4.21.1 || >4.21.1,<4.21.2 || >4.21.2,<4.21.3 || >4.21.3,<4.21.4 || >4.21.4,<4.21.5 || >4.21.5,<5.0.0.dev0"
|
||||
@ -4221,8 +4221,8 @@ files = [
|
||||
[package.dependencies]
|
||||
orjson = ">=3.9.14,<4.0.0"
|
||||
pydantic = [
|
||||
{version = ">=2.7.4,<3.0.0", markers = "python_full_version >= \"3.12.4\""},
|
||||
{version = ">=1,<3", markers = "python_full_version < \"3.12.4\""},
|
||||
{version = ">=2.7.4,<3.0.0", markers = "python_full_version >= \"3.12.4\""},
|
||||
]
|
||||
requests = ">=2,<3"
|
||||
|
||||
@ -5633,9 +5633,9 @@ bottleneck = {version = ">=1.3.6", optional = true, markers = "extra == \"perfor
|
||||
numba = {version = ">=0.56.4", optional = true, markers = "extra == \"performance\""}
|
||||
numexpr = {version = ">=2.8.4", optional = true, markers = "extra == \"performance\""}
|
||||
numpy = [
|
||||
{version = ">=1.26.0", markers = "python_version >= \"3.12\""},
|
||||
{version = ">=1.22.4", markers = "python_version < \"3.11\""},
|
||||
{version = ">=1.23.2", markers = "python_version == \"3.11\""},
|
||||
{version = ">=1.26.0", markers = "python_version >= \"3.12\""},
|
||||
]
|
||||
odfpy = {version = ">=1.4.1", optional = true, markers = "extra == \"excel\""}
|
||||
openpyxl = {version = ">=3.1.0", optional = true, markers = "extra == \"excel\""}
|
||||
@ -6194,8 +6194,8 @@ files = [
|
||||
annotated-types = ">=0.4.0"
|
||||
pydantic-core = "2.20.1"
|
||||
typing-extensions = [
|
||||
{version = ">=4.12.2", markers = "python_version >= \"3.13\""},
|
||||
{version = ">=4.6.1", markers = "python_version < \"3.13\""},
|
||||
{version = ">=4.12.2", markers = "python_version >= \"3.13\""},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
@ -6964,8 +6964,8 @@ grpcio = ">=1.41.0"
|
||||
grpcio-tools = ">=1.41.0"
|
||||
httpx = {version = ">=0.14.0", extras = ["http2"]}
|
||||
numpy = [
|
||||
{version = ">=1.26", markers = "python_version >= \"3.12\""},
|
||||
{version = ">=1.21", markers = "python_version >= \"3.8\" and python_version < \"3.12\""},
|
||||
{version = ">=1.26", markers = "python_version >= \"3.12\""},
|
||||
]
|
||||
portalocker = ">=2.7.0,<3.0.0"
|
||||
pydantic = ">=1.10.8"
|
||||
@ -9408,4 +9408,4 @@ cffi = ["cffi (>=1.11)"]
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.10"
|
||||
content-hash = "5c30434ef3021083e74389544da4176c49aae15f530f30647793e240823f3fef"
|
||||
content-hash = "8d2a12543340f6f4fa6dcb27f93d8b3f5380e7a3e7eb5e399e76e6b8588b4611"
|
||||
|
@ -121,7 +121,7 @@ flask-cors = "~4.0.0"
|
||||
flask-login = "~0.6.3"
|
||||
flask-migrate = "~4.0.5"
|
||||
flask-restful = "~0.3.10"
|
||||
flask-sqlalchemy = "~3.0.5"
|
||||
Flask-SQLAlchemy = "~3.1.1"
|
||||
gevent = "~23.9.1"
|
||||
gmpy2 = "~2.1.5"
|
||||
google-ai-generativelanguage = "0.6.1"
|
||||
|
Loading…
Reference in New Issue
Block a user