23 Commits

Author SHA1 Message Date
Vinícius Garcia
2e1aa80770 Breaking Change: changes the Exec() signature so it returns an extra value
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`
2022-02-22 16:49:48 -03:00
Vinícius Garcia
7a57e38228 Deprecate Update() in favor of a better fn name: Patch() 2022-02-22 16:14:15 -03:00
Vinícius Garcia
d1e97489ef Add some tests for invalid tables passed to Delete() 2022-02-11 17:30:42 -03:00
Vinícius Garcia
6a4ec2cd51 Update Exec signature to return the number of affected rows 2021-11-26 22:13:56 -03:00
Vinícius Garcia
a1403dc9d3 Simplify the signature of the Delete() method
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.
2021-11-22 19:42:33 -03:00
Vinícius Garcia
22fa8fdfa4 Improve the description of the Provider interface 2021-09-03 11:08:52 -03:00
Vinícius Garcia
f68b71a0a1 Merge branch 'master' into kbuilder 2021-08-08 19:34:22 -03:00
Vinícius Garcia
b6e6667a3f Improve the names of some public types *breaking change* 2021-06-28 17:35:46 -03:00
Vinícius Garcia
c0d7206dcc Breaking change: Update SQLProvider interface so methods receive table info as argument 2021-06-06 20:51:13 -03:00
Vinícius Garcia
35c1f42317 Remove var args from Insert and Update, so they actually perform atomic operations in the database 2021-03-12 11:01:36 -03:00
Vinícius Garcia
8b8fb092d8 Replace all instances of lower-cased kisssql for ksql 2021-03-10 10:11:18 -03:00
Vinícius Garcia
568c61bdba Replace all ocurrencies of KissORM for KissSQL 2021-03-08 11:18:52 -03:00
Vinícius Garcia
47dc19087f Use errors.Wrap(sql.ErrNoRows, "..") to make ErrRecordNotFound more idiomatic 2021-01-17 20:27:12 -03:00
Vinícius Garcia
5d083e35f0 Add tests for the Transaction function 2021-01-17 10:54:21 -03:00
Vinícius Garcia
9d717717d4 Add initial version of Transaction() function 2021-01-14 23:56:58 -03:00
Vinícius Garcia
20287a3740 Add Exec() function to the API 2020-12-31 13:31:30 -03:00
Vinícius Garcia
a05d26418f Improve comments for the QueryChunks func 2020-10-28 21:30:10 -03:00
Vinícius Garcia
6978474d41 Improve QueryChunks signature to be easier to use
The changes made on this commit were designed by
Raí Tamarindo (raitamarindo@gmail.com) on a previous meeting.
2020-10-28 08:55:58 -03:00
Vinícius Garcia
335c30154d Fix linter complaints 2020-10-20 21:19:57 -03:00
Vinícius Garcia
5822e23de4 Add tests to QueryChunks function
This commit also fixes some bugs on this function and
adds a feature: Now you can return an kissorm.AbortIteration
error to abort the iteration and stop processing chunks.

This does not causes the call to QueryChunks to return an error,
since this is an expected error, thus, it is just ignored.
2020-10-14 15:45:16 -03:00
Vinícius Garcia
e8bd504703 Split the Find function into the Query & QueryOne functions 2020-10-13 21:39:39 -03:00
Vinícius Garcia
a3bf34146d Replace Query&QueryNext for the new QueryChunks func 2020-10-09 15:26:00 -03:00
Vinícius Garcia
ad77d0a1a0 Add FillSliceWith helper function 2020-09-30 22:11:41 -03:00