Skip to content

Commit

Permalink
feat: allow host in dsn and use statement based transactions (#10)
Browse files Browse the repository at this point in the history
* 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
olavloite authored Aug 2, 2021
1 parent 15c95e1 commit 0528e13
Show file tree
Hide file tree
Showing 24 changed files with 5,741 additions and 1,296 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/unit-tests.yml
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
gorm/
gorm/
.idea
26 changes: 3 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

---

Expand Down
Loading

0 comments on commit 0528e13

Please sign in to comment.