Skip to content
Open
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
8 changes: 7 additions & 1 deletion internal/compiler/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/sqlc-dev/sqlc/internal/engine/dolphin"
"github.com/sqlc-dev/sqlc/internal/engine/postgresql"
pganalyze "github.com/sqlc-dev/sqlc/internal/engine/postgresql/analyzer"
"github.com/sqlc-dev/sqlc/internal/engine/postgresql/pglite"
"github.com/sqlc-dev/sqlc/internal/engine/sqlite"
sqliteanalyze "github.com/sqlc-dev/sqlc/internal/engine/sqlite/analyzer"
"github.com/sqlc-dev/sqlc/internal/opts"
Expand Down Expand Up @@ -59,7 +60,12 @@ func NewCompiler(conf config.SQL, combo config.CombinedSettings) (*Compiler, err
c.parser = postgresql.NewParser()
c.catalog = postgresql.NewCatalog()
c.selector = newDefaultSelector()
if conf.Database != nil {

// Check if PGLite analyzer is configured and experiment is enabled
exp := opts.ExperimentFromEnv()
if exp.PGLite && conf.Analyzer.PGLite != nil {
c.analyzer = pglite.New(*conf.Analyzer.PGLite)
} else if conf.Database != nil {
if conf.Analyzer.Database == nil || *conf.Analyzer.Database {
c.analyzer = analyzer.Cached(
pganalyze.New(c.client, *conf.Database),
Expand Down
8 changes: 7 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@ type SQL struct {
}

type Analyzer struct {
Database *bool `json:"database" yaml:"database"`
Database *bool `json:"database" yaml:"database"`
PGLite *PGLite `json:"pglite" yaml:"pglite"`
}

type PGLite struct {
URL string `json:"url" yaml:"url"`
SHA256 string `json:"sha256" yaml:"sha256"`
}

// TODO: Figure out a better name for this
Expand Down
Loading
Loading