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:
59
internal/sql/info/info.go
Normal file
59
internal/sql/info/info.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package info
|
||||
|
||||
import (
|
||||
"github.com/sqlc-dev/sqlc/internal/sql/catalog"
|
||||
)
|
||||
|
||||
// Provide a read-only view into the catalog
|
||||
func Newo(c *catalog.Catalog) InformationSchema {
|
||||
return InformationSchema{c: c}
|
||||
}
|
||||
|
||||
type InformationSchema struct {
|
||||
c *catalog.Catalog
|
||||
}
|
||||
|
||||
type Table struct {
|
||||
Catalog string
|
||||
Schema string
|
||||
Name string
|
||||
}
|
||||
|
||||
// SELECT * FROM information_schema.tables;
|
||||
func (i *InformationSchema) Tables() []Table {
|
||||
var tables []Table
|
||||
for _, s := range i.c.Schemas {
|
||||
for _, t := range s.Tables {
|
||||
tables = append(tables, Table{
|
||||
Catalog: i.c.Name,
|
||||
Schema: s.Name,
|
||||
Name: t.Rel.Name,
|
||||
})
|
||||
}
|
||||
}
|
||||
return tables
|
||||
}
|
||||
|
||||
type Column struct {
|
||||
Catalog string
|
||||
Schema string
|
||||
Table string
|
||||
Name string
|
||||
DataType string
|
||||
IsNullable bool
|
||||
}
|
||||
|
||||
// SELECT * FROM information_schema.columns;
|
||||
func (i *InformationSchema) Columns() []Column {
|
||||
return []Column{}
|
||||
}
|
||||
|
||||
type Schema struct {
|
||||
Catalog string
|
||||
Name string
|
||||
}
|
||||
|
||||
// SELECT * FROM information_schema.schemata;
|
||||
func (i *InformationSchema) Schemata() []Schema {
|
||||
return []Schema{}
|
||||
}
|
||||
Reference in New Issue
Block a user