Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

从基础类型转为sql.NullXXX类型时,转换失败。 #181

Open
jiang4869 opened this issue Apr 26, 2023 · 0 comments
Open

从基础类型转为sql.NullXXX类型时,转换失败。 #181

jiang4869 opened this issue Apr 26, 2023 · 0 comments
Assignees

Comments

@jiang4869
Copy link
Contributor

Reproducible Example

type User struct {
	Phone sql.NullString `json:"phone"`
}

func main() {
	phone := "12122255555"
	a := struct {
		Phone string `json:"phone"`
	}{
		Phone: phone,
	}
	u := &User{}
	err := copier.CopyWithOption(&u, a, copier.Option{DeepCopy: true, IgnoreEmpty: true})
	fmt.Println(err)
	fmt.Println(a)
	fmt.Println(u)
}

输出如下

<nil>
{12122255555}
&{{ false}} 

预期应该是

<nil>
{12122255555}
&{{12122255555 true}} 

Description

如上所述

#177 在这pr里面已经解决了这个问题,希望可以合入下一个版本中,毕竟这个问题虽然有规避方法,但是这个方法感觉不太优雅。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants