snapshot of https://github.com/ory/keto.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
CI / Run lints and checks (push) Failing after 47s
CI / Run tests (push) Failing after 1s
CI / Run race tests (push) Failing after 5s
CI / Build CLI docs (push) Has been skipped
CI / Run buf actions (push) Failing after 5s
CodeQL / Analyze (go) (push) Failing after 3s
CodeQL / Analyze (javascript) (push) Failing after 2s
Docker Image Scanners / scanners (push) Failing after 3s
Format / format (push) Failing after 3s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Draft newsletter (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
Some checks failed
CI / Run lints and checks (push) Failing after 47s
CI / Run tests (push) Failing after 1s
CI / Run race tests (push) Failing after 5s
CI / Build CLI docs (push) Has been skipped
CI / Run buf actions (push) Failing after 5s
CodeQL / Analyze (go) (push) Failing after 3s
CodeQL / Analyze (javascript) (push) Failing after 2s
Docker Image Scanners / scanners (push) Failing after 3s
Format / format (push) Failing after 3s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Draft newsletter (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
This commit is contained in:
60
oryx/popx/db_columns.go
Normal file
60
oryx/popx/db_columns.go
Normal file
@@ -0,0 +1,60 @@
|
||||
// Copyright © 2025 Ory Corp
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package popx
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/ory/pop/v6"
|
||||
)
|
||||
|
||||
func DBColumns[T any](quoter Quoter) string {
|
||||
return (&pop.Model{Value: new(T)}).Columns().QuotedString(quoter)
|
||||
}
|
||||
|
||||
// IndexHint returns the table name including the index hint, if the database
|
||||
// supports it.
|
||||
func IndexHint(conn *pop.Connection, table string, index string) string {
|
||||
if conn.Dialect.Name() == "cockroach" {
|
||||
return table + "@" + index
|
||||
}
|
||||
// PostgreSQL and YugabyteDB do not accept CockroachDB's @index syntax.
|
||||
return table
|
||||
}
|
||||
|
||||
func DBColumnsExcluding[T any](quoter Quoter, exclude ...string) string {
|
||||
cols := (&pop.Model{Value: new(T)}).Columns()
|
||||
for _, e := range exclude {
|
||||
cols.Remove(e)
|
||||
}
|
||||
return cols.QuotedString(quoter)
|
||||
}
|
||||
|
||||
type (
|
||||
AliasQuoter struct {
|
||||
Alias string
|
||||
Quoter Quoter
|
||||
}
|
||||
Quoter interface {
|
||||
Quote(key string) string
|
||||
}
|
||||
)
|
||||
|
||||
func (pq *AliasQuoter) Quote(key string) string {
|
||||
return fmt.Sprintf("%s.%s", pq.Quoter.Quote(pq.Alias), pq.Quoter.Quote(key))
|
||||
}
|
||||
|
||||
// Placeholders returns `num` placeholders ?, e.g. "?, ?, ?".
|
||||
// Placeholders(0) returns "".
|
||||
func Placeholders(num int) string {
|
||||
switch num {
|
||||
case 0:
|
||||
return ""
|
||||
case 1:
|
||||
return "?"
|
||||
default:
|
||||
return strings.Repeat("?, ", num-1) + "?"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user