Improve comments and code readability

This commit is contained in:
Marco Realacci 2023-01-10 01:21:53 +01:00
parent f6ad6db2f7
commit 3de158e5a5
19 changed files with 84 additions and 43 deletions

View file

@ -2,7 +2,7 @@ package db_errors
import "strings"
// Returns true if the query result has no rows
// Returns true if the error is a "no rows in result set" error
func EmptySet(err error) bool {
if err == nil {
return false
@ -10,6 +10,7 @@ func EmptySet(err error) bool {
return strings.Contains(err.Error(), "no rows in result set")
}
// Returns true if the error is a Unique constraint violation error
func UniqueViolation(err error) bool {
if err == nil {
return false
@ -17,6 +18,7 @@ func UniqueViolation(err error) bool {
return strings.Contains(err.Error(), "UNIQUE constraint failed")
}
// Returns true if the error is a Foreign Key constraint violation error
func ForeignKeyViolation(err error) bool {
if err == nil {
return false