Commit Graph

58 Commits (78976c1f42149f048492548a9b4e6a60f39516bc)

Author SHA1 Message Date
Igor Melo ce5c0f2890 Test ScanArgError 2023-01-30 03:01:49 -03:00
Vinícius Garcia 24599e6644 Improve NewWithAdapter to expect a dialect instead of a driver name 2022-12-21 21:23:54 -03:00
Vinícius Garcia 0f2ce0a685 Minor refactor: remove the DB.driver field 2022-12-20 23:07:39 -03:00
Vinícius Garcia d73528bd8b Add tests for the .Close() method 2022-08-03 21:21:31 -03:00
Jadson Medeiros 985254ad3e applied new refactor to test lib 2022-07-06 21:43:17 -03:00
Jadson Medeiros a1b97b1e9a changed the test lib reference 2022-07-05 21:43:56 -03:00
Vinícius Garcia e920ef6216 Refactor adapter tests to a separated file 2022-02-26 11:52:44 -03:00
Vinícius Garcia dbf6200f2c Refactor TestConfigSetDefaultValues so it breaks if we add more attributes 2022-02-26 10:52:20 -03:00
Vinícius Garcia a26397cd07 Refactor TestScanRows so its decoupled from the adapters 2022-02-26 10:49:12 -03:00
Vinícius Garcia cea28ace2b Refactor TestTransaction() so its decoupled from the adapters 2022-02-19 10:56:47 -03:00
Vinícius Garcia 90f63e5f14 Update TestQueryChunks() so its decoupled from the adapters 2022-02-19 10:52:33 -03:00
Vinícius Garcia c7e6303cbc Refactor TestUpdate() so its decoupled from the adapters 2022-02-19 10:46:57 -03:00
Vinícius Garcia 21166c93a1 Update TestDelete so its decoupled from the adapters 2022-02-19 02:58:32 -03:00
Vinícius Garcia 0b0e3a2901 Update TestInsert so its decoupled from the adapters 2022-02-19 02:55:59 -03:00
Vinícius Garcia eb030b1d76 Refactor TestQuery() to use the `tt` package 2022-02-19 02:51:07 -03:00
Vinícius Garcia b1737c8c30 Refactor TestQueryOne to use the `tt` package 2022-02-19 02:30:06 -03:00
Vinícius Garcia 9fd5bab3c4 Update TestQueryOne() so its decoupled from the adapters 2022-02-19 02:10:38 -03:00
Vinícius Garcia 488f5ba71d Refactor TestQuery() to decouple it from the DBAdapter 2022-02-15 23:51:58 -03:00
Vinícius Garcia 3e275804d0 Add a few more tests and error checks to Delete() 2022-02-12 11:50:32 -03:00
Vinícius Garcia 0b3969be1e Add test for Delete() with maps as arguments 2022-02-12 08:12:04 -03:00
Vinícius Garcia 07c6065a5b Add tests and simplify the Delete function with composite keys 2022-02-11 23:59:29 -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 49f872fb84 Add more tests for inserting in tables with composite keys 2022-02-11 17:23:47 -03:00
Vinícius Garcia 249d8db409 Improve user_permissions table used in tests for allowing more interesting tests 2022-01-25 11:32:03 -03:00
Vinícius Garcia 45e6f9ce55 Add first test for tables with composite primary keys 2022-01-22 23:25:37 -03:00
Vinícius Garcia 6f2ecbef5a Write tests for two trivial functions for raising the test coverage 2021-12-28 22:09:28 -03:00
Vinícius Garcia 1e282717b7 Remove deprecated constructors ksql.New() and ksql.NewWithPgx()
It's recommended to use instead one of:

- kpgx.New(ctx, connURL, ksql.Config{})
- kmysql.New(ctx, connURL, ksql.Config{})
- ksqlserver.New(ctx, connURL, ksql.Config{})
- ksqlite3.New(ctx, connURL, ksql.Config{})
2021-12-28 21:37:07 -03:00
Vinícius Garcia 5fffde3d34 Ignore structs not tagged with tablename on joined structs 2021-12-23 23:06:29 -03:00
Vinícius Garcia 487e2aa6ac Fix error that did not ignore fields with no ksql tags on QueryOne
The original attempt of fixing this problem was on commit:

e970a3546a
2021-12-23 22:43:33 -03:00
Vinícius Garcia fe464a217c Add docker test support for mysql 2021-12-14 23:55:49 -03:00
Vinícius Garcia 45edd4b1dd Add docker test setup for postgres
Before this commit the user would need to setup a local postgres
database manually in order to run the tests.

Now we are setting it up using docker-test which makes it easier.

We still require manual setup of sqlserver and mysql databases,
we'll fix these soon so that running the tests become trivial.
2021-12-14 23:34:26 -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 8bc726c287 Improve tests for Update() 2021-09-19 18:30:19 -03:00
Vinícius Garcia b92a751d5e Improve tests for the Delete() function 2021-09-18 21:24:22 -03:00
Vinícius Garcia 8b897d8ca9 Add error check for nil pointers passed as arguments to Delete() 2021-09-18 21:00:22 -03:00
Vinícius Garcia dffba55a8b Add error check for nil pointers passed as arguments to Update() 2021-09-18 20:52:48 -03:00
Vinícius Garcia 1cf671cd33 Add error check for nil pointers passed as arguments to Insert() 2021-09-18 18:29:00 -03:00
Vinícius Garcia 889662c4e0 Add error check for nil pointers used as arguments to QueryOne() 2021-09-18 14:42:53 -03:00
Vinícius Garcia f68b71a0a1 Merge branch 'master' into kbuilder 2021-08-08 19:34:22 -03:00
Vinícius Garcia 5c2b981696 Add tests to the pgx adapter 2021-08-01 14:42:39 -03:00
Vinícius Garcia e73db4a216 Abstract the DBAdapter so that we can support other sql adapters
This was done for a few different reasons:

1. This allows us to work on top of the pgx client in the future
2. This would allow our users to implement their own DBAdapters
   to use with our tool.
3. This gives the users the option of using advanced configs
   of any sql client they want to use and just feed us with it
   after the configuration is done, which means we will not have
   to worry about supporting a growing number of configurations
   as we try to add support to more drivers or if we get issues
   asking for more advanced config options.
2021-07-31 18:55:08 -03:00
Vinícius Garcia f420553e0b Remove risk of panic on Insert()
This panic used to happen if the user configured a table to use
a specific ID column then tried to insert to the database
with a struct that did not have that column.
2021-07-15 23:22:34 -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 2a38ae3998 Improve Update method to return ErrRecordNotFound if no rows were updated 2021-06-13 15:11:17 -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 e5c7b44e38 Add test to QueryChunks with SELECT generation 2021-06-03 20:15:18 -03:00
Vinícius Garcia ac1f94a90b Add nested struct tests for TestQueryOne 2021-05-23 15:05:01 -03:00
Vinícius Garcia 9e4583c3f8 Add error check for preventing reflection panics in nested structs 2021-05-23 12:25:35 -03:00
Vinícius Garcia 6bd61346d9 Add more tests to the nested struct feature 2021-05-23 11:32:23 -03:00