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

Automatically support "IN" clause and parameter expansion in select, exec, namedSelect, and namedExec methods #891

Open
suiriass opened this issue Aug 18, 2023 · 0 comments

Comments

@suiriass
Copy link

https://github.com/go-sqlx/sqlx/issues/18
Description:

Currently, when using the select, exec, namedSelect, and namedExec methods with an "IN" clause, we need to manually call a function to handle the parameter expansion. This can be cumbersome and less user-friendly compared to other ORM libraries like GORM, which automatically handle this.

It would be great if SQLx could automatically support the "IN" clause and parameter expansion in these methods, making it more convenient and easier to use.

Example:

Current usage:

query, args, err := sqlx.In("SELECT * FROM users WHERE id IN (?)", []int{1, 2, 3})
if err != nil {
    // handle error
}
query = db.Rebind(query)
rows, err := db.Query(query, args...)

Desired usage:

rows, err := db.Select("SELECT * FROM users WHERE id IN (?)", []int{1, 2, 3})

This enhancement would improve the developer experience and make SQLx more competitive with other ORM libraries.
The number of apis can be significantly reduced

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

1 participant