Add NewCommandTag

Useful for mocking and testing.

https://github.com/jackc/pgx/issues/1273#issuecomment-1224154013
v5-dev
Jack Christensen 2022-08-23 19:39:15 -05:00
parent fe3a4f3150
commit bb6c997102
1 changed files with 5 additions and 0 deletions

View File

@ -667,6 +667,11 @@ type CommandTag struct {
s string
}
// NewCommandTag makes a CommandTag from s.
func NewCommandTag(s string) CommandTag {
return CommandTag{s: s}
}
// RowsAffected returns the number of rows affected. If the CommandTag was not
// for a row affecting command (e.g. "CREATE TABLE") then it returns 0.
func (ct CommandTag) RowsAffected() int64 {