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

maybeExpandNamedQuery & driver.Valuer conflict #423

Open
maxatome opened this issue Sep 21, 2020 · 1 comment · May be fixed by #424
Open

maybeExpandNamedQuery & driver.Valuer conflict #423

maxatome opened this issue Sep 21, 2020 · 1 comment · May be fixed by #424

Comments

@maxatome
Copy link

Hi,

In maybeExpandNamedQuery the driver.Valuer interface is tested too late IMHO. It should be the first thing to test in this function.

If I have a map[string]x parameter that implements driver.Valuer interface, it is caught by https://github.com/go-gorp/gorp/blob/master/gorp.go#L216 test...

My use case is to have a set map[string]struct{} with a Value method that changes it to a SQL array of strings.

I can submit a PR, if you agree.

@nelsam
Copy link
Member

nelsam commented Sep 21, 2020

Sounds good to me. Might as well include the time.Time check early, too (probably in a type switch), and avoid any calls to reflect in those cases.

maxatome added a commit to maxatome/gorp that referenced this issue Sep 21, 2020
maybeExpandNamedQuery() now checks time.Time & driver.Valuer types
first before trying to check if the passed param is a map of named
params.

It allows to pass a map[string]struct{}{} type implementing
driver.Valuer without suffering any conflict with a map of named
params.

Closes go-gorp#423
maxatome added a commit to maxatome/gorp that referenced this issue Sep 21, 2020
maybeExpandNamedQuery() now checks time.Time & driver.Valuer types
first before trying to check if the passed param is a map of named
params.

It allows to pass a map[string]struct{}{} type implementing
driver.Valuer without suffering any conflict with a map of named
params.

Closes go-gorp#423
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

Successfully merging a pull request may close this issue.

2 participants