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

support slice of custom types in expandSliceArgs #427

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Songmu
Copy link
Contributor

@Songmu Songmu commented Nov 8, 2020

Support slice of custom types like []UserID(type UserID int64).

In this change, The expandSliceArgs expand if the slice element implements driver.Valuer or is of a named primitive type.

If the slice itself is of a certain type and implements driver.Valuer, expandSliceArgs does not expand the slice. So it keeps backward compatibility.

Typing as follows is reassuring in terms of type safety, and we define types in that way on our production.

In that case, this change is beneficial. What do you think?

type UserID int64

type User struct {
    ID UserID `db:"id"`
}

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 this pull request may close these issues.

1 participant