-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow host in dsn and use statement based transactions (#10)
* feat: support more options in dsn * test: add tests with mock server * refactor: transactions * feat: add comments parser * feat: parse parameters correctly * feat: support null params * test: add more tests * docs: add comments * build: fix integration tests + add GitHub actions * build: copy testutil to sql-driver and update Spanner version * chore: update copyright year * fix: address review comments
- Loading branch information
Showing
24 changed files
with
5,741 additions
and
1,296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
on: [push, pull_request] | ||
name: Unit Tests | ||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
go-version: [1.15.x, 1.16.x] | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Run unit tests | ||
run: go test -short |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
gorm/ | ||
gorm/ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,36 +73,16 @@ $ export SPANNER_EMULATOR_HOST=localhost:9010 | |
|
||
## Troubleshooting | ||
|
||
This driver shouldn't automatically retry the transactions but it does. | ||
It causes unwanted results. Don't use this library in production yet. | ||
The driver will propagate any Aborted error that is returned by Cloud Spanner | ||
during a read/write transaction, and it will currently not automatically retry | ||
the transaction. | ||
|
||
--- | ||
|
||
gorm cannot use the driver as it-is but @rakyll has been working on a dialect. | ||
She doesn't have bandwidth to ship a fully featured dialect right now but contact | ||
her if you would like to contribute. | ||
|
||
--- | ||
|
||
`error = <use T(nil), not nil>`: Use a typed nil, instead of just nil. | ||
|
||
The following query returns rows with NULL likes: | ||
|
||
``` go | ||
var nilInt64 *int64 | ||
db.QueryContext(ctx, "SELECT id, text FROM tweets WHERE likes = @likes LIMIT 10", nilInt64) | ||
``` | ||
|
||
--- | ||
|
||
When querying and executing with emails, pass them as arguments and don't hardcode | ||
them in the query: | ||
|
||
``` go | ||
db.QueryContext(ctx, "SELECT id, name ... WHERE email = @email", "[email protected]") | ||
``` | ||
|
||
The driver will relax this requirement in the future but it is a work-in-progress for now. | ||
|
||
--- | ||
|
||
|
Oops, something went wrong.