Documentation
¶
Overview ¶
Package duplicate parses PostgreSQL unique violation errors (SQLSTATE 23505) of lib/pq.
Most code should use sqlkit.IsDuplicate and sqlkit.DuplicateFields instead.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseDetail ¶
ParseDetail parses the Detail of a unique violation: "Key (a, b)=(x, y) already exists.".
fields are the names inside the first parentheses split by ", "; value is the whole content of the second parentheses (values may contain commas). An index expression such as "lower(name::text)" is returned as a single field as is. ok is false if detail is not recognized.
Types ¶
type Error ¶
type Error struct {
// Field is the column guessed from the constraint name ("users_email_key" -> "email").
Field string
// Value is the duplicated value taken from the error detail.
Value string
// Constraint is the name of the violated constraint.
Constraint string
}
Error describes a unique violation.