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
54 lines
869 B
Go
54 lines
869 B
Go
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
|
|
}
|