Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions internal/compiler/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,19 @@ func enumValueName(value string) string {
// end copypasta

func Run(conf config.SQL, combo config.CombinedSettings) (*Result, error) {
var c *catalog.Catalog
var p Parser

switch conf.Engine {
case config.EngineXLemon:
p = sqlite.NewParser()
c = catalog.New("main")
case config.EngineXDolphin:
p = dolphin.NewParser()
c = catalog.New("public") // TODO: What is the default database for MySQL?
case config.EngineXElephant:
p = postgresql.NewParser()
c = postgresql.NewCatalog()
default:
return nil, fmt.Errorf("unknown engine: %s", conf.Engine)
}
Expand All @@ -77,8 +81,7 @@ func Run(conf config.SQL, combo config.CombinedSettings) (*Result, error) {
return nil, err
}

c, err := catalog.Build(stmts)
if err != nil {
if err := c.Build(stmts); err != nil {
return nil, err
}

Expand All @@ -105,8 +108,7 @@ func Run(conf config.SQL, combo config.CombinedSettings) (*Result, error) {
switch t := typ.(type) {
case *catalog.Enum:
var name string
// TODO: This name should be public, not main
if schema.Name == "main" {
if schema.Name == c.DefaultSchema {
name = t.Name
} else {
name = schema.Name + "_" + t.Name
Expand Down
9 changes: 9 additions & 0 deletions internal/postgresql/catalog.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package postgresql

import "github.com/kyleconroy/sqlc/internal/sql/catalog"

func NewCatalog() *catalog.Catalog {
c := catalog.New("public")
c.Schemas = append(c.Schemas, &catalog.Schema{Name: "pg_temp"})
return c
}
Loading