From d2c90f4e42a3f4f82013482c9786a58c715e3948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Garcia?= Date: Sun, 6 Nov 2022 13:24:40 -0300 Subject: [PATCH] Improve docstring for global err variables --- contracts.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/contracts.go b/contracts.go index 4195b1b..6732ebd 100644 --- a/contracts.go +++ b/contracts.go @@ -6,11 +6,24 @@ import ( "fmt" ) -// ErrRecordNotFound ... +// ErrRecordNotFound informs that a given query failed because the record was not found. +// This error can be returned by the following methods: Update(), QueryOne() and Delete(). var ErrRecordNotFound error = fmt.Errorf("ksql: the query returned no results: %w", sql.ErrNoRows) + +// ErrNoValuesToUpdate informs the error of trying to make an update that would not change any attributes. +// +// This could happen if all the non-ID attributes of the struct are being ignored or if they don't exist. +// +// Since ID attributes are ignored by the Patch() method updating a struct that only have IDs will result in this error. +// And this error will also occur if the struct does have some non-ID attributes but they are all being ignored. +// +// The reasons that can cause an attribute to be ignored in the Patch() function are: +// (1) If it is a nil pointer, Patch() will just ignore it. +// (2) If the attribute is using a modifier that contains the SkipUpdates flag. var ErrNoValuesToUpdate error = fmt.Errorf("ksql: the input struct contains no values to update") -// ErrAbortIteration ... +// ErrAbortIteration should be used inside the QueryChunks function to inform QueryChunks it should stop querying, +// close the connection and return with no errors. var ErrAbortIteration error = fmt.Errorf("ksql: abort iteration, should only be used inside QueryChunks function") // Provider describes the ksql public behavior.