WIP: 增加自定义类型实现FromDB,ToDB方法,使用指针类型添加/更新时使用空更新,不使用默认值 #1541
No reviewers
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: xorm/xorm#1541
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "master"
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?
一般我们使用指针类型定义数据库对应可空字段,此PR实现自定义类型(实现Conversion接口),使用指针类型插入更新数据时使用<空>更新数据存储值,非指针类型更新保持0值初始化同原始设计
Could you add some tests?
比方说我自己实现个Time,
模型类定义
指针类型对应数据可为空的字段,先前的逻辑,如果是指针类型会在数据库中插入空字符串,而我希望是null,PR就是解决这问题
上面的例子还有个特殊的问题,我的Time是time.Time的别名类型,如果按先前逻辑,空指针(EndTime)会在数据库是插入空字符串,而空字符串不是有效的timestamptz类型,会造成插入更新失败
I know that. Please add your tests on some test file, maybe
time_test.go
. Once the CI pass, I could merge it.Yeah, I've added tests.
@venjiang CI failed.
Pull request closed