49 Commits
Author SHA1 Message Date
Alan Shreve 97c9c04efc Merge pull request #22 from antoinedeschenes/fix-ctx-tests
fix linting issues in tests
2022-05-20 10:35:18 -07:00
Antoine Deschênes 0c3f7c4193 fix linting issues 2022-05-20 13:12:19 -04:00
Alan Shreve 2e797f3a38 Merge pull request #21 from antoinedeschenes/allow-editing-wrap-context
Allow interceptor to edit wrapped contexts
2022-05-20 09:25:54 -07:00
Antoine Deschênes 78a3d8957a Allow editing wrap contexts
Signed-off-by: Antoine Deschênes <antoine@antoinedeschenes.com>
2022-05-09 12:46:27 -04:00
Alan Shreve 9d16fdc47b Merge pull request #20 from tcolgate/rowsgenfix
rows_picker_gen: fixes for rows picker code generation
2021-12-20 09:55:33 -08:00
Tristan Colgate 1ec8ad714f rows_picker_gen: fixes for rows picker code generation 2021-12-20 09:55:06 +00:00
Alan Shreve 35873b76a3 Merge pull request #19 from tcolgate/rows
rows: Support all optional interfaces for driver.Rows
2021-12-14 09:44:26 -08:00
Tristan Colgate 7aff84f564 rows: fix PR feedback 2021-12-14 12:38:31 +00:00
Tristan Colgate-McFarlaneandFabian Holler f4f50f46dc Apply suggestions from code review
Co-authored-by: Fabian Holler <mail@fholler.de>
2021-12-09 15:05:37 +00:00
Tristan Colgate-McFarlaneandFabian Holler 9a80f8992b Update rows_test.go
Co-authored-by: Fabian Holler <mail@fholler.de>
2021-12-09 15:01:48 +00:00
Tristan Colgate 431a31d1a9 tests: add testing or rows wrapping 2021-12-08 17:03:24 +00:00
Tristan Colgate 94c8fe0daa tests: add more realistic rows testing 2021-12-08 14:15:57 +00:00
Tristan Colgate 373c16969b rows: fix use of Unwrap 2021-12-03 08:54:10 +00:00
Tristan Colgate 4cbdd019d7 rows: alternate RowsUnwrap doc string 2021-12-03 08:26:41 +00:00
Tristan Colgate-McFarlaneandFabian Holler 1edd769383 Update rows.go
Co-authored-by: Fabian Holler <mail@fholler.de>
2021-12-03 07:58:44 +00:00
Tristan Colgate 0293201729 rows: fix PR feedback 2021-12-02 16:28:25 +00:00
Alan Shreve bf4246b997 Add syntax highlighting for README examples 2021-12-02 06:36:53 -08:00
Tristan Colgate 32b3ff36e7 rows: Support all optional interfaces for driver.Rows
This uses some code generation to wrap an incoming rows in a type
that supports the exact set of interfaces that are supported by
the original type.
2021-11-25 13:56:13 +00:00
Alan Shreve 7475ecc88b Merge pull request #18 from tcolgate/master
conn: support IsValid
2021-11-24 08:35:06 -08:00
Tristan Colgate bfc60ed7da conn: support IsValid 2021-11-24 10:24:15 +00:00
Alan Shreve 241da6c2de Merge pull request #12 from fho/def_converter_test
tests: add test that ensures driver.DefaultParameterConverter is used
2021-08-19 17:39:40 -04:00
Alan Shreve ccd5b5fa44 Merge pull request #13 from fho/ci_setup
Setup CI using github-actions
2021-08-19 17:38:31 -04:00
Fabian Holler 6d76ec1dfb connector: remove unused connect() method
golangci-lint complained about that connect() is unused.
The private method was indeed never called, remove it.
2021-08-19 09:49:14 +02:00
Fabian Holler 59f3bcf052 golangci-lint: add annotations to ignore non-relevant warnings 2021-08-19 09:48:36 +02:00
Fabian Holler 2c9196e88f golangci-lint: add config to ignore deprecated db method use warnings
Add a configuration file for golangci-lint that contains an exclude rule
to ignore warnings about the use of deprecated db methods and
interfaces.
Those warnings are not relevant, sqlmw supports older go versions
therefore those must be implemented.
2021-08-19 09:45:48 +02:00
Fabian Holler 2a20a55ff2 ci: add a github-action config to introduce basic CI checks
- build the lib
- run the tests
- run golangci-lint checks.
2021-08-19 09:36:35 +02:00
Fabian Holler 448d2c43b1 tests: add test that ensures driver.DefaultParameterConverter is used
Add a testcases that ensures the driver.DefaultParameterConverter is
used to convert db args for stmts when neither the stmt nor con
implements any value converter methods.
2021-08-19 09:19:52 +02:00
Alan Shreve 9a9596d93c Merge pull request #11 from fho/revert-8-column_converter
Revert "call stmt.ColumnConverter when implemented by parent statement"
2021-08-18 13:25:31 -04:00
Fabian Holler 7a95e4dbba Revert "call stmt.ColumnConverter when implemented by parent statement"
My change caused that driver.DefaultParameterConverter is not called
anymore sometimes.
For example when the lib/pq driver is used, uint32 args passed to
stmt.Exec() are not converted by driver.DefaultParameterConverter to
int64 anymore.
This causes that the lib/pq driver operation fails because the argument
is passed unconverted, as unsupported type.

I could not reproduce the behavior in a testcase with the fakedb driver.
The driver.DefaultParameterConverter was called and the type was passed
converted to stmt.Exec(), as expected.

I don't understand yet why this happens with the lib/pq driver with my
change.

Revert it for now. That the deprecated ColumnConverter is not called by
sqlmw, is a lesser issue compared to the one that was introduced by my
change.
2021-08-18 19:13:40 +02:00
Alan Shreve 08b4749a9c Merge pull request #9 from fho/row_close_interceptor
support intercepting Rows.Close() calls
2021-08-16 10:35:43 -04:00
Fabian Holler c3dd4a90c4 tests: add testcase for rows.Close()
The testcase verifies:
- that the interceptor forwards the rows.Close() the driver.Rows.Close()
  function and
- that the ctx passed to Interceptor.RowsClose() is the one that is
  specified in the QueryContext() call.
2021-08-16 16:31:28 +02:00
Fabian Holler 0a7c4e0a56 Revert "rowsClose: remove unused context parameter"
This reverts commit 10c6b86df1.
2021-08-05 17:24:52 +02:00
Fabian Holler 10c6b86df1 rowsClose: remove unused context parameter 2021-08-05 17:15:07 +02:00
Fabian Holler dc1b9181df support intercepting Rows.Close() calls
Add a new RowsClose() method to the interceptor interface to which
rows.Close() calls are forwarded.

Intercepting rows.Close() can be useful in tracing middlewares.
It allows to create a parent span when the db Rows object is
created, create child spans for operations on the Rows and finish the
parent span when rows.Close() is called.
2021-08-05 17:11:21 +02:00
Alan Shreve d58d4d92af Merge pull request #8 from fho/column_converter
call stmt.ColumnConverter when implemented by parent statement
2021-08-03 09:30:06 -07:00
Fabian Holler 1e77bed04f call stmt.ColumnConverter when implemented by parent statement
According to the stdlib driver documentation
(https://github.com/golang/go/blob/bc51e930274a5d5835ac8797978afc0864c9e30c/src/database/sql/driver/driver.go#L385)
value checkers should be called in the following order:

> [..] stopping at the first found match: Stmt.NamedValueChecker,
> Conn.NamedValueChecker, Stmt.ColumnConverter,
> DefaultParameterConverter.

sqlmw was not calling Stmt.ColumnConverter when it was implemented.

This commit changes the behavior to call Stmt.ColumnConverter, if it is
implemented and the NamedValueCheckers are not implemented.
This is done by returning ErrSkip in wrappedStmt.CheckNamedValue() if
neither the parent statement nor the conn implements CheckNamedValue.
The sql package will call wrappedStmt.ColumnConverter() if ErrSkip was
returned.

wrappedStmt.CheckNamedValue() can not check only if the stmt
implements CheckNamedValue and return ErrSkip.
It must also call CheckNamedValue() on the connection if it
was not implemented for the stmt. This is because the stdlib sql package
calls wrappedStmt.CheckNamedValue() if is implemented on the stmt OR on
the connection.

The commit also adds a testcase to verify that ColumnConverter is
called.
2021-08-03 11:05:09 +02:00
Alan Shreve d5c93a81be Merge pull request #3 from ohayn/use-with-mysql-driver
Check both statement and connection
2020-01-29 13:37:57 -08:00
ohayn 5b03e94d0c Fix cs 2020-01-29 16:46:39 +09:00
ohayn 3f95e0f013 Add tests for stmt's CheckNamedValue 2020-01-29 15:54:49 +09:00
ohayn d70f58520d Use driver.DefaultParameterConverter 2020-01-28 16:19:45 +09:00
ohayn 151ef4ca2a Check both statement and connection 2020-01-28 16:19:15 +09:00
Alan Shreve 58cf87fb38 Merge pull request #1 from jgeiger/patch-1
Fix typos in README.md
2020-01-17 15:49:21 -08:00
Joey Geiger d71c677d95 Fix typos in README.md
Noticed a few typos while reading and fixed them.
2020-01-17 16:48:08 -07:00
Alan Shreve e501dc06a5 add some examples 2020-01-15 15:20:05 -08:00
Alan Shreve 803b24a81e make tests pass 2020-01-15 14:54:56 -08:00
Alan Shreve 45469026a6 fix package name 2020-01-15 00:22:34 -08:00
Alan Shreve 4c0dc175b9 ngrok owned 2020-01-15 00:05:40 -08:00
Alan Shreve cd8c5c50d6 cleanup 2020-01-15 00:02:44 -08:00
Alan Shreve 0b3c0470d8 initial prototype of sqlmw 2020-01-14 23:10:09 -08:00