Skip to content

Commit 26ef08b

Browse files
committed
fix: let sqlc output nullable array
Close #1851 This remove 2 assumptions from the code: - type cast are no longer always non null - postgres can output nullable array
1 parent 6389cdc commit 26ef08b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

internal/codegen/golang/postgresql_type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func parseIdentifierString(name string) (*plugin.Identifier, error) {
3636

3737
func postgresType(req *plugin.GenerateRequest, options *opts.Options, col *plugin.Column) string {
3838
columnType := sdk.DataType(col.Type)
39-
notNull := col.NotNull || col.IsArray
39+
notNull := col.NotNull
4040
driver := parseDriver(options.SqlPackage)
4141
emitPointersForNull := driver.IsPGX() && options.EmitPointersForNullTypes
4242

internal/compiler/resolve.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ func (comp *Compiler) resolveCatalogRefs(qc *QueryCatalog, rvs []*ast.RangeVar,
512512
return nil, fmt.Errorf("*ast.TypeCast has nil type name")
513513
}
514514
col := toColumn(n.TypeName)
515-
defaultP := named.NewInferredParam(col.Name, col.NotNull)
515+
defaultP := named.NewInferredParam(col.Name, false)
516516
p, _ := params.FetchMerge(ref.ref.Number, defaultP)
517517

518518
col.Name = p.Name()
@@ -633,5 +633,6 @@ func (comp *Compiler) resolveCatalogRefs(qc *QueryCatalog, rvs []*ast.RangeVar,
633633
addUnknownParam(ref)
634634
}
635635
}
636+
636637
return a, nil
637638
}

0 commit comments

Comments
 (0)