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
28 changes: 0 additions & 28 deletions internal/compiler/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"
"os"
"path/filepath"
"regexp"
"strings"

"github.com/kyleconroy/sqlc/internal/metadata"
Expand All @@ -25,33 +24,6 @@ type Parser interface {
IsReservedKeyword(string) bool
}

// copied over from gen.go
func structName(name string) string {
out := ""
for _, p := range strings.Split(name, "_") {
if p == "id" {
out += "ID"
} else {
out += strings.Title(p)
}
}
return out
}

var identPattern = regexp.MustCompile("[^a-zA-Z0-9_]+")

func enumValueName(value string) string {
name := ""
id := strings.Replace(value, "-", "_", -1)
id = strings.Replace(id, ":", "_", -1)
id = strings.Replace(id, "/", "_", -1)
id = identPattern.ReplaceAllString(id, "")
for _, part := range strings.Split(id, "_") {
name += strings.Title(part)
}
return name
}

// end copypasta
func (c *Compiler) parseCatalog(schemas []string) error {
files, err := sqlpath.Glob(schemas)
Expand Down
58 changes: 0 additions & 58 deletions internal/engine/dolphin/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,64 +7,6 @@ import (
"github.com/kyleconroy/sqlc/internal/sql/ast"
)

type nodeSearch struct {
list []pcast.Node
check func(pcast.Node) bool
}

func (s *nodeSearch) Enter(n pcast.Node) (pcast.Node, bool) {
if s.check(n) {
s.list = append(s.list, n)
}
return n, false // skipChildren
}

func (s *nodeSearch) Leave(n pcast.Node) (pcast.Node, bool) {
return n, true // ok
}

func collect(root pcast.Node, f func(pcast.Node) bool) []pcast.Node {
if root == nil {
return nil
}
ns := &nodeSearch{check: f}
root.Accept(ns)
return ns.list
}

type nodeVisit struct {
fn func(pcast.Node)
}

func (s *nodeVisit) Enter(n pcast.Node) (pcast.Node, bool) {
s.fn(n)
return n, false // skipChildren
}

func (s *nodeVisit) Leave(n pcast.Node) (pcast.Node, bool) {
return n, true // ok
}

func visit(root pcast.Node, f func(pcast.Node)) {
if root == nil {
return
}
ns := &nodeVisit{fn: f}
root.Accept(ns)
}

// Maybe not useful?
func text(nodes []pcast.Node) []string {
str := make([]string, len(nodes))
for i := range nodes {
if nodes[i] == nil {
continue
}
str[i] = nodes[i].Text()
}
return str
}

func parseTableName(n *pcast.TableName) *ast.TableName {
return &ast.TableName{
Schema: identifier(n.Schema.String()),
Expand Down
9 changes: 0 additions & 9 deletions internal/engine/postgresql/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,3 @@ func NewCatalog() *catalog.Catalog {
c.LoadExtension = loadExtension
return c
}

// The generated pg_catalog is very slow to compare because it has so
// many entries. For testing, don't include it.
func newTestCatalog() *catalog.Catalog {
c := catalog.New("public")
c.Schemas = append(c.Schemas, pgTemp())
c.LoadExtension = loadExtension
return c
}
12 changes: 0 additions & 12 deletions internal/engine/postgresql/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,6 @@ func convertSlice(nodes []*pg.Node) *ast.List {
return out
}

func convertValuesList(l [][]*pg.Node) *ast.List {
out := &ast.List{}
for _, outer := range l {
o := &ast.List{}
for _, inner := range outer {
o.Items = append(o.Items, convertNode(inner))
}
out.Items = append(out.Items, o)
}
return out
}

func convert(node *pg.Node) (ast.Node, error) {
return convertNode(node), nil
}
Expand Down
4 changes: 0 additions & 4 deletions internal/engine/postgresql/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,6 @@ func parseColName(node *nodes.Node) (*ast.ColumnRef, *ast.TableName, error) {
}
}

func join(list *nodes.List, sep string) string {
return strings.Join(stringSlice(list), sep)
}

func joinNodes(list []*nodes.Node, sep string) string {
return strings.Join(stringSliceFromNodes(list), sep)
}
Expand Down
19 changes: 0 additions & 19 deletions internal/engine/postgresql/pg_temp.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,9 @@
package postgresql

import (
"github.com/kyleconroy/sqlc/internal/sql/ast"
"github.com/kyleconroy/sqlc/internal/sql/catalog"
)

func pgTemp() *catalog.Schema {
return &catalog.Schema{Name: "pg_temp"}
}

func typeName(name string) *ast.TypeName {
return &ast.TypeName{Name: name}
}

func argN(name string, n int) *catalog.Function {
var args []*catalog.Argument
for i := 0; i < n; i++ {
args = append(args, &catalog.Argument{
Type: &ast.TypeName{Name: "any"},
})
}
return &catalog.Function{
Name: name,
Args: args,
ReturnType: &ast.TypeName{Name: "any"},
}
}
4 changes: 0 additions & 4 deletions internal/engine/sqlite/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ type tableNamer interface {
Schema_name() parser.ISchema_nameContext
}

type multiselect interface {
AllSelect_core() []parser.ISelect_coreContext
}

func parseTableName(c tableNamer) *ast.TableName {
name := ast.TableName{
Name: c.Table_name().GetText(),
Expand Down
12 changes: 0 additions & 12 deletions internal/sql/ast/varatt_external.go

This file was deleted.

7 changes: 0 additions & 7 deletions internal/sql/ast/vartag_external.go

This file was deleted.

12 changes: 0 additions & 12 deletions internal/sql/catalog/func.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,6 @@ func (f *Function) InArgs() []*Argument {
return args
}

func (c *Catalog) getFunc(rel *ast.FuncName, tns []*ast.TypeName) (*Function, int, error) {
ns := rel.Schema
if ns == "" {
ns = c.DefaultSchema
}
s, err := c.getSchema(ns)
if err != nil {
return nil, -1, err
}
return s.getFunc(rel, tns)
}

func (c *Catalog) createFunction(stmt *ast.CreateFunctionStmt) error {
ns := stmt.Func.Schema
if ns == "" {
Expand Down