Skip to content

Commit dde69d9

Browse files
committed
dolphin: Placeholder catalog for count(*)
1 parent 1486a09 commit dde69d9

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

internal/compiler/engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func NewCompiler(conf config.SQL, combo config.CombinedSettings) *Compiler {
2727
c.catalog = catalog.New("main")
2828
case config.EngineMySQL, config.EngineMySQLBeta:
2929
c.parser = dolphin.NewParser()
30-
c.catalog = catalog.New("public") // TODO: What is the default database for MySQL?
30+
c.catalog = dolphin.NewCatalog()
3131
case config.EnginePostgreSQL:
3232
c.parser = postgresql.NewParser()
3333
c.catalog = postgresql.NewCatalog()

internal/engine/dolphin/catalog.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package dolphin
2+
3+
import (
4+
"github.com/kyleconroy/sqlc/internal/sql/ast"
5+
"github.com/kyleconroy/sqlc/internal/sql/catalog"
6+
)
7+
8+
func NewCatalog() *catalog.Catalog {
9+
def := "public" // TODO: What is the default database for MySQL?
10+
return &catalog.Catalog{
11+
DefaultSchema: def,
12+
Schemas: []*catalog.Schema{
13+
&catalog.Schema{
14+
Name: def,
15+
Funcs: []*catalog.Function{
16+
{
17+
Name: "count",
18+
Args: []*catalog.Argument{
19+
{
20+
Type: &ast.TypeName{Name: "any"},
21+
},
22+
},
23+
ReturnType: &ast.TypeName{Name: "bigint"},
24+
},
25+
{
26+
Name: "count",
27+
Args: []*catalog.Argument{},
28+
ReturnType: &ast.TypeName{Name: "bigint"},
29+
},
30+
},
31+
},
32+
},
33+
Extensions: map[string]struct{}{},
34+
}
35+
}

0 commit comments

Comments
 (0)