File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package popx
2+
3+ import (
4+ "github.com/ory/pop/v6"
5+ )
6+
7+ func DBColumns [T any ](quoter Quoter ) string {
8+ return (& pop.Model {Value : new (T )}).Columns ().QuotedString (quoter )
9+ }
10+
11+ // IndexHint returns the table name including the index hint, if the database
12+ // supports it.
13+ func IndexHint (conn * pop.Connection , table string , index string ) string {
14+ if conn .Dialect .Name () == "cockroach" {
15+ return table + "@" + index
16+ }
17+ return table
18+ }
19+
20+ func WritableDBColumnNames [T any ]() []string {
21+ var names []string
22+ for _ , c := range (& pop.Model {Value : new (T )}).Columns ().Writeable ().Cols {
23+ names = append (names , c .Name )
24+ }
25+ return names
26+ }
27+
28+ func DBColumnsExcluding [T any ](quoter Quoter , exclude ... string ) string {
29+ cols := (& pop.Model {Value : new (T )}).Columns ()
30+ for _ , e := range exclude {
31+ cols .Remove (e )
32+ }
33+ return cols .QuotedString (quoter )
34+ }
35+
36+ type (
37+ PrefixQuoter struct {
38+ Prefix string
39+ Quoter Quoter
40+ }
41+ Quoter interface {
42+ Quote (key string ) string
43+ }
44+ )
45+
46+ func (pq * PrefixQuoter ) Quote (key string ) string {
47+ return pq .Quoter .Quote (pq .Prefix + key )
48+ }
You can’t perform that action at this time.
0 commit comments