Skip to content

Commit

Permalink
feat: force clientFoundRows to true (#727)
Browse files Browse the repository at this point in the history
* feat: force clientFoundRows to true

* fix: adjust golangci lint

* test: update assertion
  • Loading branch information
aeneasr authored Oct 6, 2023
1 parent 78da4d7 commit 45f6c90
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
uses: golangci/golangci-lint-action@v3
with:
skip-go-installation: true
args: --timeout 2m
args: --timeout 5m
- name: Install cockroach DB
run: |
curl https://binaries.cockroachdb.com/cockroach-v22.2.5.linux-amd64.tgz | tar -xz
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ licenses: .bin/licenses node_modules # checks open-source licenses
GOBIN=$(shell pwd)/.bin go install golang.org/x/tools/cmd/goimports@latest

.bin/golangci-lint: Makefile
bash <(curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh) -d -b .bin v1.46.2
bash <(curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh) -d -b .bin v1.54.2

.bin/licenses: Makefile
curl https://raw.githubusercontent.com/ory/ci/master/licenses/install | sh
Expand Down
4 changes: 4 additions & 0 deletions sqlcon/parse_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ func FinalizeDSN(l *logrusx.Logger, dsn string) string {
q.Set("multiStatements", "true")
q.Set("parseTime", "true")

// Thius causes an UPDATE to return the number of matching rows instead of
// the number of rows changed. This ensures compatibility with PostgreSQL and SQLite behavior.
q.Set("clientFoundRows", "true")

return fmt.Sprintf("%s?%s", parts[0], q.Encode())
}

Expand Down
6 changes: 3 additions & 3 deletions sqlcon/parse_opts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ func TestFinalizeDSN(t *testing.T) {
}{
{
dsn: "mysql://localhost",
expected: "mysql://localhost?multiStatements=true&parseTime=true",
expected: "mysql://localhost?clientFoundRows=true&multiStatements=true&parseTime=true",
},
{
dsn: "mysql://localhost?multiStatements=true&parseTime=true",
expected: "mysql://localhost?multiStatements=true&parseTime=true",
dsn: "mysql://localhost?multiStatements=true&parseTime=true&clientFoundRows=false",
expected: "mysql://localhost?clientFoundRows=true&multiStatements=true&parseTime=true",
},
{
dsn: "postgres://localhost",
Expand Down

0 comments on commit 45f6c90

Please sign in to comment.