Repository navigation
add onupdate=func.current_timestamp() - #28014
Conversation
734b1c0 to
2f3d488
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request consistently adds onupdate=func.current_timestamp() to updated_at fields across various SQLAlchemy models. This is a great improvement as it ensures timestamps are automatically updated at the database level, enhancing data integrity. I've also noticed and appreciate the consistency changes from db.* to sa.* in several models.
My main feedback is regarding the use of default=datetime.now in api/models/oauth.py. For consistency with the rest of the codebase and to avoid potential timezone issues, it would be better to use server_default=func.current_timestamp() here as well. I've left specific suggestions for this.
There was a problem hiding this comment.
Pull Request Overview
This PR adds automatic timestamp updates to updated_at fields across multiple database models by adding onupdate=func.current_timestamp() parameter, and standardizes the use of the sa. prefix instead of db. in certain model files for consistency.
- Adds
onupdate=func.current_timestamp()toupdated_atfields across provider, oauth, model, dataset, and account model classes - Fixes inconsistent usage of
db.Texttosa.Textin workflow.py - Standardizes table constraint and column definitions from
db.prefix tosa.prefix in oauth.py and dataset.py
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| api/models/workflow.py | Adds onupdate parameter to updated_at field and corrects db.Text to sa.Text for consistency |
| api/models/provider.py | Adds onupdate=func.current_timestamp() to all provider-related model updated_at fields |
| api/models/oauth.py | Adds onupdate to timestamp fields and standardizes db. to sa. prefix throughout the file |
| api/models/model.py | Adds onupdate=func.current_timestamp() to updated_at fields across App and related models |
| api/models/dataset.py | Adds onupdate to dataset-related model timestamp fields and standardizes constraint prefixes |
| api/models/account.py | Adds onupdate=func.current_timestamp() to Account, Tenant, and related model updated_at fields |
Comments suppressed due to low confidence (1)
api/models/oauth.py:67
- The
updated_atfield usesdefault=datetime.nowfor creation timestamps butonupdate=func.current_timestamp()for updates. This creates an inconsistency where inserts use Python-evaluated time while updates use database-evaluated time. Consider usingserver_default=func.current_timestamp()instead ofdefault=datetime.nowto ensure both creation and updates use database time consistently, matching the pattern used in other model files likeprovider.pyandmodel.py.
sa.DateTime, nullable=False, default=datetime.now, onupdate=func.current_timestamp()
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request consistently adds onupdate=func.current_timestamp() to updated_at columns across numerous SQLAlchemy models. This is a beneficial change as it leverages the database's native capabilities to automatically manage update timestamps, improving data integrity and reducing application-level logic. The changes are well-implemented. I've pointed out a minor redundancy in api/models/oauth.py where both Python-side and database-side defaults are specified for created_at columns, which could be simplified.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request consistently adds onupdate=func.current_timestamp() to updated_at fields across numerous models, which is an excellent improvement to ensure timestamps are automatically managed by the database. The changes also include beneficial refactoring, such as replacing client-side default=datetime.now with server_default and standardizing on sqlalchemy (sa) imports instead of the Flask-SQLAlchemy db object. I've found one critical issue in api/models/workflow.py related to a python-side default being evaluated at definition time, and I've provided a suggestion to fix it and improve consistency.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request correctly adds onupdate=func.current_timestamp() to updated_at columns across various models, which is a great improvement for ensuring data integrity at the database level. The changes also include beneficial refactoring, such as replacing db.* with sa.* for consistency and fixing some timestamp default value implementations. I've added one comment regarding an opportunity to apply the db to sa refactoring more consistently in api/models/dataset.py. Overall, these are solid improvements.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request consistently adds onupdate=func.current_timestamp() to updated_at columns across numerous SQLAlchemy models, which is a great improvement for ensuring data integrity by letting the database manage update timestamps. The changes also include beneficial refactorings, such as moving from client-side to server-side default timestamps and standardizing SQLAlchemy imports. I've identified a minor inconsistency in api/models/dataset.py where different functions are used for server_default and onupdate in the same column definition. Aligning these would improve code consistency. Overall, this is a valuable set of changes.
| updated_at: Mapped[datetime] = mapped_column( | ||
| DateTime, | ||
| nullable=False, | ||
| default=naive_utc_now(), |
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* test: adding some web tests (langgenius#27792) * feat: add validation to prevent saving empty opening statement in conversation opener modal (langgenius#27843) * fix(web): improve the consistency of the inputs-form UI (langgenius#27837) * fix(web): increase z-index of PortalToFollowElemContent (langgenius#27823) * fix: installation_id is missing when in tools page (langgenius#27849) * fix: avoid passing empty uniqueIdentifier to InstallFromMarketplace (langgenius#27802) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * test: create new test scripts and update some existing test scripts o… (langgenius#27850) * feat: change feedback to forum (langgenius#27862) * chore: translate i18n files and update type definitions (langgenius#27868) Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> * Fix/template transformer line number (langgenius#27867) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> * bump vite to 6.4.1 (langgenius#27877) * Add WEAVIATE_GRPC_ENDPOINT as designed in weaviate migration guide (langgenius#27861) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * Fix: correct DraftWorkflowApi.post response model (langgenius#27289) Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * fix Version 2.0.0-beta.2: Chat annotations Api Error langgenius#25506 (langgenius#27206) Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Asuka Minato <i@asukaminato.eu.org> * fix jina reader creadential migration command (langgenius#27883) * fix agent putout the output of workflow-tool twice (langgenius#26835) (langgenius#27087) * fix jina reader transform (langgenius#27922) * fix: prevent fetch version info in enterprise edition (langgenius#27923) * fix(api): fix `VariablePool.get` adding unexpected keys to variable_dictionary (langgenius#26767) Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * refactor: implement tenant self queue for rag tasks (langgenius#27559) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com> * fix: bump brotli to 1.2.0 resloved CVE-2025-6176 (langgenius#27950) Signed-off-by: kenwoodjw <blackxin55+@gmail.com> * docs: clarify how to obtain workflow_id for version execution (langgenius#28007) Signed-off-by: OneZero-Y <aukovyps@163.com> * fix: fix langgenius#27939 (langgenius#27985) * fix: the model list encountered two children with the same key (langgenius#27956) Co-authored-by: haokai <haokai@shuwen.com> * add onupdate=func.current_timestamp() (langgenius#28014) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * chore(deps): bump scipy-stubs from 1.16.2.3 to 1.16.3.0 in /api (langgenius#28025) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fix typo in weaviate comment, improve time test precision, and add security tests for get-icon utility (langgenius#27919) Signed-off-by: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * feat: Add Audio Content Support for MCP Tools (langgenius#27979) * fix: elasticsearch_vector version (langgenius#28028) Co-authored-by: huangzhuo <huangzhuo1@xiaomi.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * fix workflow default updated_at (langgenius#28047) * feat(api): Introduce Broadcast Channel (langgenius#27835) This PR introduces a `BroadcastChannel` abstraction with broadcasting and at-most once delivery semantics, serving as the communication component between celery worker and API server. It also includes a reference implementation backed by Redis PubSub. Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * fix * back --------- Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com> Signed-off-by: kenwoodjw <blackxin55+@gmail.com> Signed-off-by: OneZero-Y <aukovyps@163.com> Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com> Co-authored-by: aka James4u <smart.jamesjin@gmail.com> Co-authored-by: Novice <novice12185727@gmail.com> Co-authored-by: yangzheli <43645580+yangzheli@users.noreply.github.com> Co-authored-by: Elliott <105957288+Elliott-byte@users.noreply.github.com> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: johnny0120 <johnny0120@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Gritty_dev <101377478+codomposer@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: wangjifeng <163279492+kk-wangjifeng@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Boris Polonsky <BorisPolonsky@users.noreply.github.com> Co-authored-by: Yongtao Huang <yongtaoh2022@gmail.com> Co-authored-by: Cursx <33718736+Cursx@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Asuka Minato <i@asukaminato.eu.org> Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: red_sun <56100962+redSun64@users.noreply.github.com> Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: QuantumGhost <obelisk.reg+git@gmail.com> Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: hj24 <huangjian@dify.ai> Co-authored-by: kenwoodjw <blackxin55+@gmail.com> Co-authored-by: OneZero-Y <aukovyps@163.com> Co-authored-by: wangxiaolei <fatelei@gmail.com> Co-authored-by: Kenn <kennfalcon@gmail.com> Co-authored-by: haokai <haokai@shuwen.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com> Co-authored-by: Will <vvfriday@gmail.com> Co-authored-by: huangzhuo1949 <167434202+huangzhuo1949@users.noreply.github.com> Co-authored-by: huangzhuo <huangzhuo1@xiaomi.com>
* test: adding some web tests (langgenius#27792) * feat: add validation to prevent saving empty opening statement in conversation opener modal (langgenius#27843) * fix(web): improve the consistency of the inputs-form UI (langgenius#27837) * fix(web): increase z-index of PortalToFollowElemContent (langgenius#27823) * fix: installation_id is missing when in tools page (langgenius#27849) * fix: avoid passing empty uniqueIdentifier to InstallFromMarketplace (langgenius#27802) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * test: create new test scripts and update some existing test scripts o… (langgenius#27850) * feat: change feedback to forum (langgenius#27862) * chore: translate i18n files and update type definitions (langgenius#27868) Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> * Fix/template transformer line number (langgenius#27867) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> * bump vite to 6.4.1 (langgenius#27877) * Add WEAVIATE_GRPC_ENDPOINT as designed in weaviate migration guide (langgenius#27861) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * Fix: correct DraftWorkflowApi.post response model (langgenius#27289) Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * fix Version 2.0.0-beta.2: Chat annotations Api Error langgenius#25506 (langgenius#27206) Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Asuka Minato <i@asukaminato.eu.org> * fix jina reader creadential migration command (langgenius#27883) * fix agent putout the output of workflow-tool twice (langgenius#26835) (langgenius#27087) * fix jina reader transform (langgenius#27922) * fix: prevent fetch version info in enterprise edition (langgenius#27923) * fix(api): fix `VariablePool.get` adding unexpected keys to variable_dictionary (langgenius#26767) Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * refactor: implement tenant self queue for rag tasks (langgenius#27559) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com> * fix: bump brotli to 1.2.0 resloved CVE-2025-6176 (langgenius#27950) Signed-off-by: kenwoodjw <blackxin55+@gmail.com> * docs: clarify how to obtain workflow_id for version execution (langgenius#28007) Signed-off-by: OneZero-Y <aukovyps@163.com> * fix: fix langgenius#27939 (langgenius#27985) * fix: the model list encountered two children with the same key (langgenius#27956) Co-authored-by: haokai <haokai@shuwen.com> * add onupdate=func.current_timestamp() (langgenius#28014) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * chore(deps): bump scipy-stubs from 1.16.2.3 to 1.16.3.0 in /api (langgenius#28025) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fix typo in weaviate comment, improve time test precision, and add security tests for get-icon utility (langgenius#27919) Signed-off-by: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * feat: Add Audio Content Support for MCP Tools (langgenius#27979) * fix: elasticsearch_vector version (langgenius#28028) Co-authored-by: huangzhuo <huangzhuo1@xiaomi.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * fix workflow default updated_at (langgenius#28047) * feat(api): Introduce Broadcast Channel (langgenius#27835) This PR introduces a `BroadcastChannel` abstraction with broadcasting and at-most once delivery semantics, serving as the communication component between celery worker and API server. It also includes a reference implementation backed by Redis PubSub. Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * Chore: change query log time range (langgenius#28052) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * tmp ci * fix * chore: Remove trailing space from migration filename (langgenius#28040) * chore: translate i18n files and update type definitions (langgenius#28054) Co-authored-by: iamjoel <2120155+iamjoel@users.noreply.github.com> * tmp ci * fix --------- Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com> Signed-off-by: kenwoodjw <blackxin55+@gmail.com> Signed-off-by: OneZero-Y <aukovyps@163.com> Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com> Co-authored-by: aka James4u <smart.jamesjin@gmail.com> Co-authored-by: Novice <novice12185727@gmail.com> Co-authored-by: yangzheli <43645580+yangzheli@users.noreply.github.com> Co-authored-by: Elliott <105957288+Elliott-byte@users.noreply.github.com> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: johnny0120 <johnny0120@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Gritty_dev <101377478+codomposer@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: wangjifeng <163279492+kk-wangjifeng@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Boris Polonsky <BorisPolonsky@users.noreply.github.com> Co-authored-by: Yongtao Huang <yongtaoh2022@gmail.com> Co-authored-by: Cursx <33718736+Cursx@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Asuka Minato <i@asukaminato.eu.org> Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: red_sun <56100962+redSun64@users.noreply.github.com> Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: QuantumGhost <obelisk.reg+git@gmail.com> Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: hj24 <huangjian@dify.ai> Co-authored-by: kenwoodjw <blackxin55+@gmail.com> Co-authored-by: OneZero-Y <aukovyps@163.com> Co-authored-by: wangxiaolei <fatelei@gmail.com> Co-authored-by: Kenn <kennfalcon@gmail.com> Co-authored-by: haokai <haokai@shuwen.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com> Co-authored-by: Will <vvfriday@gmail.com> Co-authored-by: huangzhuo1949 <167434202+huangzhuo1949@users.noreply.github.com> Co-authored-by: huangzhuo <huangzhuo1@xiaomi.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: iamjoel <2120155+iamjoel@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Important
Fixes #<issue number>.Summary
fix #28013
Screenshots
Checklist
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint gods