Skip to content
Next Next commit
Default schema
  • Loading branch information
Andrey Yanakov committed Dec 23, 2022
commit 780b95d17d6fda6062cd7ca3451e1b83f26560ef
2 changes: 1 addition & 1 deletion internal/compiler/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewCompiler(conf config.SQL, combo config.CombinedSettings) *Compiler {
c.catalog = dolphin.NewCatalog()
case config.EnginePostgreSQL:
c.parser = postgresql.NewParser()
c.catalog = postgresql.NewCatalog()
c.catalog = postgresql.NewCatalog(c.conf.DefaultSchema)
default:
panic(fmt.Sprintf("unknown engine: %s", conf.Engine))
}
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ type GenGo struct {
type SQL struct {
Engine Engine `json:"engine,omitempty" yaml:"engine"`
Schema Paths `json:"schema" yaml:"schema"`
DefaultSchema string `json:"default_schema" yaml:"default_schema"`
Queries Paths `json:"queries" yaml:"queries"`
StrictFunctionChecks bool `json:"strict_function_checks" yaml:"strict_function_checks"`
Gen SQLGen `json:"gen" yaml:"gen"`
Expand Down
7 changes: 5 additions & 2 deletions internal/engine/postgresql/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ func toPointer(x int) *int {
return &x
}

func NewCatalog() *catalog.Catalog {
c := catalog.New("public")
func NewCatalog(defaultSchema string) *catalog.Catalog {
if defaultSchema == "" {
defaultSchema = "public"
}
c := catalog.New(defaultSchema)
c.Schemas = append(c.Schemas, pgTemp())
c.Schemas = append(c.Schemas, genPGCatalog())
c.Schemas = append(c.Schemas, genInformationSchema())
Expand Down