Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support repeated named parameters
This fixes `got %v argument values, but found %v parameters in the sql string` error when using repeated named arguments. The "workaround" is to specify as many parameters as observed. The last one will win due to `prepareSpannerStmt` using map keyed by name. Due to this change the `Bad` examples will start to return an error. Example: ```golang // Bad: @name will be "value2" s.db.QueryRow( "SELECT * FROM users WHERE (first_name=@name OR last_name=@name)", sql.Named("name", "value"), sql.Named("name", "value2"), ) // Bad: @name will be "value2" s.db.QueryRow( "SELECT * FROM users WHERE (first_name=@name OR last_name=@name)", "value", "value2", ) // Good: works, ideal usage s.db.QueryRow( "SELECT * FROM users WHERE (first_name=@name OR last_name=@name)", sql.Named("name", "value"), ) // Good: not ideal, inferred positional arguments s.db.QueryRow( "SELECT * FROM users WHERE (first_name=@name OR last_name=@name)", "value", ) ``` Signed-off-by: Kamil Trzciński <[email protected]>
- Loading branch information