Skip to content

Improve panic output with rows.AddRow #325

@co60ca

Description

@co60ca

Proposal

panic("Expected number of values to match number of columns")

This panic can be confusing, its simple enough to debug if you know what you're doing but if you pass a string withlen() = 25 it will of course panic if the developer does not spreading. Like with: rows.AddRow(v) vs rows.AddRow(v...) (Spreading will cause another issue with []string but I digress.

The former will compile but will panic. I wonder if you'd accept it to say "Expected number of values to match number of columns, expected %d, actual %d" to at least hint.

I wonder if this is acceptable or if it would break backwards compatibility in an unacceptable way. If you'd accept this change I'd gladly provide a PR.

Use-cases

Changing the panic message should simplify debugging sqlmock during development.

Otherwise we can close.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions