解决Conversion接口ToDB() ([]byte, error)方法返回*Type值为nil时,数据类型为[]byte(nil)的… #1296
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
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: xorm/xorm#1296
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "peihexian/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?
解决字段类型为*Type,值为nil时,插入数据变为""的bug。解决update操作时,*Type类型字段的值为nil时,数据值变成[]byte(nil)的bug,正确的情况应该是interface(nil)。
Codecov Report
68.05% <0%> (+0.19%)
22.19% <0%> (-0.1%)
52.38% <0%> (-3.76%)
57.41% <0%> (-2.32%)
77.09% <0%> (-2.22%)
61.53% <0%> (-1.06%)
56.44% <0%> (-0.18%)
56.84% <0%> (-0.12%)
0% <0%> (ø)
76.11% <0%> (+0.15%)
Continue to review full report at Codecov.
为什么不给合并?是不是没有说清楚? 自定义类型例如 type MyTime time.Time 这种,如果在struct里面使用时是指针类型的话,例如 type Student struct {
Name string
Birthday *MyTime
} 这种情况,需要为MyTime去实现Conversion接口,向数据库写入是ToDB方面,该方法返回值类型是[]byte ,error,如果Birthday字段用户并没有输入数据值的话,也就是Birthday字段值为nil的话,ToDB方法只能返回nil,但是因为已经限定了数据类型是[]byte,所以数据库引擎在执行时给该字段赋值为[]byte(nil)这样的参数数据,这种[]byte(nil)数据库引擎是不认的,但是改为interface(nil)的话就可以正确识别为NULL,所以加了上面改动那些代码,不知道用中文说明白没有?
Could you add some tests?