TimeField skips validators for timedelta values
维护者通常 4 天内回复
评估
调研方向
Start by reading TimeField.to_db_value() in the field implementation and the existing validation tests. Reproduce the issue with the provided negative timedelta, then check that configured validators run and a valid timedelta is returned unchanged. The linked pull request #2405 is already open, so this work is underway.
由索引模型根据 Issue 内容生成。
描述
TimeField.to_db_value() returns timedelta values before calling the configured validators. These values are supported by the field and are returned by MySQL time columns.
from datetime import timedelta
from tortoise.fields import TimeField
from tortoise.exceptions import ValidationError
def reject_negative(value):
if value < timedelta():
raise ValidationError("negative time")
field = TimeField(validators=[reject_negative])
field.to_db_value(timedelta(hours=-1), object())
This returns the negative timedelta without raising on current develop. The field's normal validation path is skipped entirely for that type.
Removing the early return should let the existing validation call run while preserving the timedelta value. Reproduced directly on Python 3.14 without a database connection. A regression also checks that a valid timedelta is returned unchanged.
- 主要语言
- Python
- 星标
- 5.6k
- 派生
- 543
- 平均合并
- 4 天 17 小时
- 30 天内合并 PR
- 33
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
tortoise/tortoise-orm 的其他 Issue
-
Automatic DatetimeField values bypass custom validators可能已有人在做 @IlyaKhalafi 于 4 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 83/100
tortoise/tortoise-orm#2409 ·
维护者通常 4 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
tortoise/tortoise-orm#668 ·
维护者通常 4 天内回复
-
UUIDField skips configured validators when writing values可能已有人在做 @IlyaKhalafi 于 5 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 25/100
tortoise/tortoise-orm#2407 ·
维护者通常 4 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
tortoise/tortoise-orm#2406 ·
维护者通常 4 天内回复
-
in_transaction() leaks a pool connection when begin() is cancelled可能已有人在做 @inchang-ing 于 9 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 45/100
tortoise/tortoise-orm#2391 ·
维护者通常 4 天内回复
查看 tortoise/tortoise-orm 的全部 Issue
相似的 Issue
-
question
难度 1/5 1 小时以内 新手友好度 68/100
vllm-project/vime#524 ·
维护者通常 7 天内回复
-
WOPI editor page is scrollable by a few pixels, which breaks scrolling in the document (Firefox)未关闭
难度 2/5 1-3 小时 新手友好度 84/100
suitenumerique/drive#969 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
theupdateframework/python-tuf#3044 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
FAIRmat-NFDI/pynxtools#861 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
NVIDIA/nsight-python#88 ·
维护者通常 1 天内回复