snapshot of https://github.com/sqlc-dev/sqlc.git (main, 2026-09-16; blobs > 131072B omitted)
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
This commit is contained in:
53
internal/engine/postgresql/utils.go
Normal file
53
internal/engine/postgresql/utils.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package postgresql
|
||||
|
||||
import (
|
||||
nodes "github.com/sqlc-dev/oliphant"
|
||||
)
|
||||
|
||||
func isArray(n *nodes.TypeName) bool {
|
||||
if n == nil {
|
||||
return false
|
||||
}
|
||||
return len(n.ArrayBounds) > 0
|
||||
}
|
||||
|
||||
func isNotNull(n *nodes.ColumnDef) bool {
|
||||
if n.IsNotNull {
|
||||
return true
|
||||
}
|
||||
for _, c := range n.Constraints {
|
||||
switch inner := c.Node.(type) {
|
||||
case *nodes.Node_Constraint:
|
||||
if inner.Constraint.Contype == nodes.ConstrType_CONSTR_NOTNULL {
|
||||
return true
|
||||
}
|
||||
if inner.Constraint.Contype == nodes.ConstrType_CONSTR_PRIMARY {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func makeByte(s string) byte {
|
||||
var b byte
|
||||
if s == "" {
|
||||
return b
|
||||
}
|
||||
return []byte(s)[0]
|
||||
}
|
||||
|
||||
func makeUint32Slice(in []uint64) []uint32 {
|
||||
out := make([]uint32, len(in))
|
||||
for i, v := range in {
|
||||
out[i] = uint32(v)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func makeString(s string) *string {
|
||||
if s == "" {
|
||||
return nil
|
||||
}
|
||||
return &s
|
||||
}
|
||||
Reference in New Issue
Block a user