Skip to content

Commit 0b26e27

Browse files
aeneasrory-bot
authored andcommitted
fix(changelog-oel): replace returning * with defined column names
GitOrigin-RevId: 8fa1912556293bba8f9c841ec316da18a52ea61e
1 parent f5b1e6b commit 0b26e27

File tree

5 files changed

+38
-33
lines changed

5 files changed

+38
-33
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ jobs:
3232
- name: Run tests
3333
run: ./test/conformance/test.sh -v -short -parallel 16
3434

35-
3635
test:
3736
name: Run tests and lints
3837
runs-on: ubuntu-latest
@@ -130,8 +129,8 @@ jobs:
130129
runs-on: ubuntu-latest
131130
strategy:
132131
matrix:
133-
database: [ "memory", "postgres", "mysql", "cockroach" ]
134-
args: [ "", "--jwt" ]
132+
database: ["memory", "postgres", "mysql", "cockroach"]
133+
args: ["", "--jwt"]
135134
services:
136135
postgres:
137136
image: postgres:16

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ require (
3434
github.com/ory/hydra-client-go/v2 v2.2.1
3535
github.com/ory/jsonschema/v3 v3.0.9-0.20250317235931-280c5fc7bf0e
3636
github.com/ory/kratos-client-go v1.3.8
37-
github.com/ory/x v0.0.712
37+
github.com/ory/x v0.0.718
3838
github.com/pborman/uuid v1.2.1
3939
github.com/pkg/errors v0.9.1
4040
github.com/prometheus/client_golang v1.21.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,8 @@ github.com/ory/kratos-client-go v1.3.8 h1:S4D5dAURq5C6LbOUU+DgE4ZXxp37IlJG2Gngem
409409
github.com/ory/kratos-client-go v1.3.8/go.mod h1:Dc+ANapsPxu+CfdC0yk8TxmvceCmrvNozW+ZGS/xq5o=
410410
github.com/ory/pop/v6 v6.2.1-0.20241121111754-e5dfc0f3344b h1:BIzoOe2/wynZBQak1po0tzgvARseIKsR2bF6b+SZoKE=
411411
github.com/ory/pop/v6 v6.2.1-0.20241121111754-e5dfc0f3344b/go.mod h1:okVAYKGtgunD/wbW3NGhZTndJCS+6FqO+cA89rQ4doc=
412-
github.com/ory/x v0.0.712 h1:3HRRXBlKXwkIh5ag55fs25tIMipb058muNtEWTFOqfI=
413-
github.com/ory/x v0.0.712/go.mod h1:FxgJl980fq/41JTPPloNawYPCY25KRYuMO98SRk1czc=
412+
github.com/ory/x v0.0.718 h1:/zsayNY4XWfzjIk5o8ytkEgLsVO8onz0qIotW5ue3TU=
413+
github.com/ory/x v0.0.718/go.mod h1:FxgJl980fq/41JTPPloNawYPCY25KRYuMO98SRk1czc=
414414
github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw=
415415
github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
416416
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=

persistence/sql/persister_consent.go

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -518,54 +518,46 @@ func (p *Persister) CreateLoginSession(ctx context.Context, session *flow.LoginS
518518
return nil
519519
}
520520

521-
func (p *Persister) DeleteLoginSession(ctx context.Context, id string) (deletedSession *flow.LoginSession, err error) {
521+
func (p *Persister) DeleteLoginSession(ctx context.Context, id string) (_ *flow.LoginSession, err error) {
522522
ctx, span := p.r.Tracer(ctx).Tracer().Start(ctx, "persistence.sql.DeleteLoginSession")
523523
defer otelx.End(span, &err)
524524

525-
if p.Connection(ctx).Dialect.Name() == "mysql" {
525+
c := p.Connection(ctx)
526+
if c.Dialect.Name() == "mysql" {
526527
// MySQL does not support RETURNING.
527528
return p.mySQLDeleteLoginSession(ctx, id)
528529
}
529530

530531
var session flow.LoginSession
531-
532-
err = p.Connection(ctx).RawQuery(
533-
`DELETE FROM hydra_oauth2_authentication_session
534-
WHERE id = ? AND nid = ?
535-
RETURNING *`,
532+
columns := pop.NewModel(&session, ctx).Columns().Readable()
533+
if err := p.Connection(ctx).RawQuery(
534+
fmt.Sprintf(
535+
`DELETE FROM hydra_oauth2_authentication_session WHERE id = ? AND nid = ? RETURNING %s`,
536+
columns.QuotedString(c.Dialect)),
536537
id,
537538
p.NetworkID(ctx),
538-
).First(&session)
539-
if err != nil {
539+
).First(&session); err != nil {
540540
return nil, sqlcon.HandleError(err)
541541
}
542542

543543
return &session, nil
544544
}
545545

546-
func (p *Persister) mySQLDeleteLoginSession(ctx context.Context, id string) (*flow.LoginSession, error) {
547-
var session flow.LoginSession
546+
func (p *Persister) mySQLDeleteLoginSession(ctx context.Context, id string) (_ *flow.LoginSession, err error) {
547+
ctx, span := p.r.Tracer(ctx).Tracer().Start(ctx, "persistence.sql.mySQLDeleteLoginSession")
548+
defer otelx.End(span, &err)
548549

549-
err := p.Connection(ctx).Transaction(func(tx *pop.Connection) error {
550-
err := tx.RawQuery(`
551-
SELECT * FROM hydra_oauth2_authentication_session
552-
WHERE id = ? AND nid = ?`,
553-
id,
554-
p.NetworkID(ctx),
555-
).First(&session)
556-
if err != nil {
550+
var session flow.LoginSession
551+
if err := p.Connection(ctx).Transaction(func(tx *pop.Connection) error {
552+
if err := tx.Where("id = ? AND nid = ?", id, p.NetworkID(ctx)).First(&session); err != nil {
557553
return err
558554
}
559555

560-
return p.Connection(ctx).RawQuery(`
561-
DELETE FROM hydra_oauth2_authentication_session
562-
WHERE id = ? AND nid = ?`,
563-
id,
564-
p.NetworkID(ctx),
556+
return tx.RawQuery(
557+
`DELETE FROM hydra_oauth2_authentication_session WHERE id = ? AND nid = ?`,
558+
id, p.NetworkID(ctx),
565559
).Exec()
566-
})
567-
568-
if err != nil {
560+
}); err != nil {
569561
return nil, sqlcon.HandleError(err)
570562
}
571563

test/main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"github.com/gobuffalo/pop/v6"
7+
"github.com/ory/hydra/v2/flow"
8+
)
9+
10+
func main() {
11+
var session flow.LoginSession
12+
13+
fmt.Printf("%+v", pop.NewModel(&session, context.Background()).Columns().Readable().SelectString())
14+
}

0 commit comments

Comments
 (0)