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:
39
internal/core/namespace.go
Normal file
39
internal/core/namespace.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func (c *Catalog) CreateNamespace(name string) (int64, error) {
|
||||
oid, err := c.q.CreateNamespace(context.Background(), name)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("create namespace %q: %w", name, err)
|
||||
}
|
||||
return oid, nil
|
||||
}
|
||||
|
||||
func (c *Catalog) NamespaceOID(name string) (int64, error) {
|
||||
oid, err := c.q.NamespaceOID(context.Background(), name)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("namespace %q: %w", name, err)
|
||||
}
|
||||
return oid, nil
|
||||
}
|
||||
|
||||
type NamespaceInfo struct {
|
||||
OID int64
|
||||
Name string
|
||||
}
|
||||
|
||||
func (c *Catalog) Namespaces() ([]NamespaceInfo, error) {
|
||||
rows, err := c.q.ListNamespaces(context.Background())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("list namespaces: %w", err)
|
||||
}
|
||||
out := make([]NamespaceInfo, 0, len(rows))
|
||||
for _, r := range rows {
|
||||
out = append(out, NamespaceInfo{OID: r.Oid, Name: r.Name})
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
Reference in New Issue
Block a user