Skip to content

Commit e396b6b

Browse files
committed
fix: explcit columns list in the select statement
1 parent d3e690d commit e396b6b

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

.github/workflows/testing.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@ jobs:
2828
--health-retries 5
2929
3030
steps:
31-
- name: Set up Go
32-
uses: actions/setup-go@v2
3331
- name: Check out code
3432
uses: actions/checkout@v3
33+
34+
- name: Set up Go
35+
uses: actions/setup-go@v3
36+
with:
37+
go-version-file: ./go.mod
38+
3539
- name: Run tests
3640
if: success()
3741
run: go test -timeout 60s -cover ./... -coverprofile=coverage.txt -covermode=atomic

Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
lint:
22
@echo "$(OK_COLOR)==> Linting with golangci-lint$(NO_COLOR)"
3-
@docker run --rm -v `pwd`:/app -w /app golangci/golangci-lint:v1.27.0 golangci-lint run -v
3+
@docker run --rm -v `pwd`:/app -w /app golangci/golangci-lint:v1.54.2 golangci-lint run -v
44

55
test:
66
@echo "$(OK_COLOR)==> Running tests using docker-compose deps$(NO_COLOR)"
7-
@docker-compose up -d
8-
@sleep 3 && \
9-
PG_URI="postgres://test:test@`docker-compose port postgres 5432`/test?sslmode=disable" \
7+
@docker compose up -d --wait
8+
@PG_URI="postgres://test:test@`docker-compose port postgres 5432`/test?sslmode=disable" \
109
go test -timeout 60s -cover -coverprofile=coverage.txt -covermode=atomic ./...

client_store.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ func NewClientStore(adapter pgAdapter.Adapter, options ...ClientStoreOption) (*C
5757
func (s *ClientStore) initTable() error {
5858
return s.adapter.Exec(context.Background(), fmt.Sprintf(`
5959
CREATE TABLE IF NOT EXISTS %[1]s (
60-
id TEXT NOT NULL,
61-
secret TEXT NOT NULL,
62-
domain TEXT NOT NULL,
63-
data JSONB NOT NULL,
60+
"id" TEXT NOT NULL,
61+
"secret" TEXT NOT NULL,
62+
"domain" TEXT NOT NULL,
63+
"data" JSONB NOT NULL,
6464
CONSTRAINT %[1]s_pkey PRIMARY KEY (id)
6565
);
6666
`, s.tableName))
@@ -79,7 +79,7 @@ func (s *ClientStore) GetByID(ctx context.Context, id string) (oauth2.ClientInfo
7979
}
8080

8181
var item ClientStoreItem
82-
if err := s.adapter.SelectOne(ctx, &item, fmt.Sprintf("SELECT * FROM %s WHERE id = $1", s.tableName), id); err != nil {
82+
if err := s.adapter.SelectOne(ctx, &item, fmt.Sprintf(`SELECT "id", "secret", "domain", "data" FROM "%s" WHERE "id" = $1`, s.tableName), id); err != nil {
8383
return nil, err
8484
}
8585

@@ -95,7 +95,7 @@ func (s *ClientStore) Create(info oauth2.ClientInfo) error {
9595

9696
return s.adapter.Exec(
9797
context.Background(),
98-
fmt.Sprintf("INSERT INTO %s (id, secret, domain, data) VALUES ($1, $2, $3, $4)", s.tableName),
98+
fmt.Sprintf(`INSERT INTO %s ("id", "secret", "domain", "data") VALUES ($1, $2, $3, $4)`, s.tableName),
9999
info.GetID(),
100100
info.GetSecret(),
101101
info.GetDomain(),

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: "3"
33

44
services:
55
postgres:
6-
image: postgres:9.6-alpine
6+
image: postgres:11-alpine
77
ports:
88
- '5432'
99
environment:
@@ -14,7 +14,7 @@ services:
1414
tmpfs:
1515
- /var/lib/postgresql/data
1616
healthcheck:
17-
test: ["CMD", "pg_isready"]
17+
test: [ "CMD", "pg_isready" ]
1818
interval: 10s
1919
timeout: 5s
2020
retries: 5

0 commit comments

Comments
 (0)