Skip to content

database/sql: QueryRow should verify that we have only one row #20163

@RaduBerinde

Description

@RaduBerinde

QueryRow is documented as follows:

// QueryRow executes a query that is expected to return at most one row.
// QueryRow always returns a non-nil value. Errors are deferred until
// Row's Scan method is called.

This suggests that we should get an error if the query returns more than one row. However Row.Scan() doesn't check that r.rows.Next() returns false after processing one row, so it would ignore any remaining rows.

Conversely "at most one row" suggests that getting no rows is somehow acceptable, but an error is returned in that case. I think it should say "exactly one row".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions