Default 字段不生效 #1731
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: xorm/xorm#1731
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?
当engine.Insert(data)时,data中不含某些字段,但是这些字段在model中定义了default值,然后数据库中的记录并没有应用那个default值,而是个空值或者0
Maybe we should add a
Default(cols...)
method when insert#2101
这个问题就有点冲突了。
如果是 sql.NullInt32 / sql.NullTime / sql.NullFloat64 这类的就有点冲突了
也就是无法判断 到底是使用 null 值,还是 default 值。因为这是三种状态(有值,null值,default值),
如果使用 driver.Valuer 来判断,只能判断两种状态,是无法实现3状态区分。无法细分猜测到用户到底要哪种
这个方案不会冲突了,由用户在外层来决定。但是缺点就是没办法类型内部决定到底要用3值中的哪一种值,也是比较头疼的冲突。
先不说自定义类型和sql.NullXXX,就是基础类型int都不行???default成摆设了(xorm.io/xorm v1.3.4)?
We don't know whether 0 is a meaningful value except you use *int. This is decided by Golang's features.
你看 Num11_Ptr_DefNum 和 Num12_Ptr_DefStr ,int* 一样不支持 。。 @lunny
在新的golang 1.22中,官方增加了 sql.Null[T] ,不知道是否有设计思路。
https://pkg.go.dev/database/sql#Null