File tree Expand file tree Collapse file tree 2 files changed +6
-12
lines changed Expand file tree Collapse file tree 2 files changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package cmd
2
2
3
3
import (
4
4
"encoding/json"
5
- "fmt"
6
5
"strings"
7
6
8
7
gopluginopts "github.com/sqlc-dev/sqlc/internal/codegen/golang/opts"
@@ -39,7 +38,7 @@ func pluginOverride(r *compiler.Result, o config.Override) *plugin.Override {
39
38
40
39
var options []byte
41
40
var err error
42
- if o .Options . IsZero () {
41
+ if len ( o .Options ) == 0 {
43
42
// Send go-specific override information to the go codegen plugin
44
43
options , err = json .Marshal (gopluginopts.OverrideOptions {
45
44
GoType : o .GoType ,
@@ -49,12 +48,7 @@ func pluginOverride(r *compiler.Result, o config.Override) *plugin.Override {
49
48
panic (err ) // TODO don't panic, return err
50
49
}
51
50
} else {
52
- options , err = convert .YAMLtoJSON (o .Options )
53
- if err != nil {
54
- panic (err )
55
- }
56
-
57
- fmt .Printf (">>> %s" , string (options ))
51
+ options = o .Options
58
52
}
59
53
60
54
return & plugin.Override {
Original file line number Diff line number Diff line change 1
1
package config
2
2
3
3
import (
4
+ "encoding/json"
4
5
"fmt"
5
6
"os"
6
7
"strings"
7
8
8
9
gopluginopts "github.com/sqlc-dev/sqlc/internal/codegen/golang/opts"
9
10
"github.com/sqlc-dev/sqlc/internal/pattern"
10
- "gopkg.in/yaml.v3"
11
11
)
12
12
13
13
type Override struct {
@@ -43,8 +43,8 @@ type Override struct {
43
43
TableRel * pattern.Match `json:"-"`
44
44
45
45
// For passing plugin-specific configuration
46
- Plugin string `json:"plugin,omitempty"`
47
- Options yaml. Node `json:"options,omitempty"`
46
+ Plugin string `json:"plugin,omitempty"`
47
+ Options json. RawMessage `json:"options,omitempty"`
48
48
}
49
49
50
50
func (o Override ) hasGoOptions () bool {
@@ -78,7 +78,7 @@ func (o *Override) Parse() (err error) {
78
78
return fmt .Errorf ("Override specifying both `column` (%q) and `db_type` (%q) is not valid." , o .Column , o .DBType )
79
79
case o .Column == "" && o .DBType == "" :
80
80
return fmt .Errorf ("Override must specify one of either `column` or `db_type`" )
81
- case o .hasGoOptions () && ! o .Options . IsZero () :
81
+ case o .hasGoOptions () && len ( o .Options ) > 0 :
82
82
return fmt .Errorf ("Override can specify go_type/go_struct_tag or options but not both" )
83
83
}
84
84
You can’t perform that action at this time.
0 commit comments