marcboeker / go-duckdb

go-duckdb provides a database/sql driver for the DuckDB database engine.
MIT License
583 stars 96 forks source link

Add support for named parameters #227

Closed ajzo90 closed 1 month ago

ajzo90 commented 1 month ago

This PR adds support for named parameters. It tries to keeps old behaviour intact, but introduces some vague interpretation since it can mix named and non-named parameters. Possibly a better alternative is to check whether named or positional parameters are used and do strict validation.

stmt, _ := db.Prepare("SELECT $foo, $bar")
_ = stmt.QueryRow(sql.Named("foo", 1), sql.Named("bar", "baz"))`