From 9e052131ce234138e00a81b87e094c62378515e9 Mon Sep 17 00:00:00 2001 From: Andrew Benton Date: Sun, 30 Jul 2023 17:48:37 -0400 Subject: [PATCH 1/2] refactor(compiler): remove some duplicate code --- internal/compiler/to_column.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/internal/compiler/to_column.go b/internal/compiler/to_column.go index 726b7ff32c..3267107c8b 100644 --- a/internal/compiler/to_column.go +++ b/internal/compiler/to_column.go @@ -7,13 +7,6 @@ import ( "github.com/sqlc-dev/sqlc/internal/sql/astutils" ) -func isArray(n *ast.TypeName) bool { - if n == nil || n.ArrayBounds == nil { - return false - } - return len(n.ArrayBounds.Items) > 0 -} - func arrayDims(n *ast.TypeName) int { if n == nil || n.ArrayBounds == nil { return 0 @@ -29,11 +22,12 @@ func toColumn(n *ast.TypeName) *Column { if err != nil { panic("toColumn: " + err.Error()) } + arrayDims := arrayDims(n) return &Column{ Type: typ, DataType: strings.TrimPrefix(astutils.Join(n.Names, "."), "."), NotNull: true, // XXX: How do we know if this should be null? - IsArray: isArray(n), - ArrayDims: arrayDims(n), + IsArray: arrayDims > 0, + ArrayDims: arrayDims, } } From 0bc7472d31d3a644480a82339a41db6d377b5a2e Mon Sep 17 00:00:00 2001 From: Andrew Benton Date: Sun, 30 Jul 2023 17:51:38 -0400 Subject: [PATCH 2/2] fix(compiler): remove duplicate code --- internal/compiler/compat.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/internal/compiler/compat.go b/internal/compiler/compat.go index 55a70417b3..097d889cfb 100644 --- a/internal/compiler/compat.go +++ b/internal/compiler/compat.go @@ -14,11 +14,6 @@ func stringSlice(list *ast.List) []string { for _, item := range list.Items { if n, ok := item.(*ast.String); ok { items = append(items, n.Str) - continue - } - if n, ok := item.(*ast.String); ok { - items = append(items, n.Str) - continue } } return items