This commit adds these modifiers:
1. skipUpdates (with unit tests)
2. skipInserts (with unit tests)
3. skipQueries (no tests yet) (and not really working yet)
And handles two situations previously not considered:
1. Updates with no attributes will now return a properly formatted
error instead of returning a syntax error.
2. Inserts with no values will now work on SQLite, Postgres and
SQLServer
This reverts commit 74cb87bea0.
This was done because I noticed this first commit was unnecessary.
This original commit was written in order to allow tests where
the cache would return errors, but I noticed there is a way
of provoking these errors without the need of an extra layer
of abstraction.
Thus, in order to keep the code simpler and also avoid an extra
level of indirection I am undoing this change.
As known, a map can't be accessed with read/write concurrently on
multiple goroutines. This just replaces all uses of global maps for
caches with sync.Map, which is safe to be used concurrently.
The signature was updated from
- `Exec(...) (rowsAffected int64, _ error)`
To:
- `Exec(...) (ksql.Result, error)`
Result is an interface, so it should be easy to mock, we are also
providing a new builtin mock struct + constructor to make it even easier:
Building new mock Result: `ksql.NewMockResult(lastInsertID int64, rowsAffected int64) Result`
This change was finally made because the Delete function was the
only helper function that was not returning the ksql.ErrRecordNotFound
when no rows were found.
The other reason for this change is that we the most common use case is
by far for deleting a single element, and the philosophy of the library
is to optimize for the most common use-cases.
For making it easier to write queries for deleting many items
as well as many other less common use cases we
are already implementing the `kbuilder` package which is a
query builder.