Skip to content

Commit b131f02

Browse files
refactor(compiler): remove some duplicate code (#2546)
* refactor(compiler): remove some duplicate code * fix(compiler): remove duplicate code
1 parent 6762871 commit b131f02

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

internal/compiler/compat.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ func stringSlice(list *ast.List) []string {
1414
for _, item := range list.Items {
1515
if n, ok := item.(*ast.String); ok {
1616
items = append(items, n.Str)
17-
continue
18-
}
19-
if n, ok := item.(*ast.String); ok {
20-
items = append(items, n.Str)
21-
continue
2217
}
2318
}
2419
return items

internal/compiler/to_column.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ import (
77
"github.com/sqlc-dev/sqlc/internal/sql/astutils"
88
)
99

10-
func isArray(n *ast.TypeName) bool {
11-
if n == nil || n.ArrayBounds == nil {
12-
return false
13-
}
14-
return len(n.ArrayBounds.Items) > 0
15-
}
16-
1710
func arrayDims(n *ast.TypeName) int {
1811
if n == nil || n.ArrayBounds == nil {
1912
return 0
@@ -29,11 +22,12 @@ func toColumn(n *ast.TypeName) *Column {
2922
if err != nil {
3023
panic("toColumn: " + err.Error())
3124
}
25+
arrayDims := arrayDims(n)
3226
return &Column{
3327
Type: typ,
3428
DataType: strings.TrimPrefix(astutils.Join(n.Names, "."), "."),
3529
NotNull: true, // XXX: How do we know if this should be null?
36-
IsArray: isArray(n),
37-
ArrayDims: arrayDims(n),
30+
IsArray: arrayDims > 0,
31+
ArrayDims: arrayDims,
3832
}
3933
}

0 commit comments

Comments
 (0)