貌似不支持 sql.NullTime #2099
Labels
No Label
backport/done
backport/v1
blocked
db
oracle
db
sqlserver
duplicate
feature
cache
frontport/done
frontport/main
invalid
kind
breaking
kind
bug
kind
build
kind
dependencies
kind
docs
kind
driver
kind
enhancement
kind
feature
kind
performance
kind
proposal
kind
question
kind
refactor
kind
testing
need
feedback
need
test
proposal:accepted
RaspBerry Pi
regression
skip-changelog
upstream
wip
wontfix
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: xorm/xorm#2099
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
现象:我自定义了一个类型,封装了 sql.NullTime
在 insert 的时候,报错了 “panic: reflect.Value.Convert: value of type time.Time cannot be converted to type db.Time”
我跟了一下,发现应该和自动时间戳有关
xorm 生成里 time.Time 的时间戳,然后貌似不知道该怎么转换
session_insert.go -> genInsertColumns -> setColumnTime
还有一个问题,insert 的时候,能不能通过类型的 Value() 看以下是否为 nil,如果为 nil 就不要拼 insert 的 sql 文了
现在的现象是,使用了类似 sql.NullSting 的类型,然后在定义 model 时直接使用了 sql.NullSting,而没用 *sql.NullSting
然后 new(Model),这个字段就必然不是 nil,但是它的 Value() 是 nil 啊,但是 insert sql 会把这个字段拼上,导致数据库如果不允许为 null,但是有默认值,也仍然无法 insert 成功
@Lunny Xiao 我本地这样该的,报错就好了,但不知道这样改是不是最优的