Skip to content

Commit

Permalink
Allow sql_driver: "github.com/go-sql-driver/mysql"
Browse files Browse the repository at this point in the history
In preparation of sqlc-dev#2179 for LOAD DATA LOCAL INFILE
  • Loading branch information
Jille committed Apr 21, 2023
1 parent e99f1db commit d6560ce
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 160 deletions.
1 change: 1 addition & 0 deletions internal/cmd/shim.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func pluginGoCode(s config.SQLGo) *plugin.GoCode {
Package: s.Package,
Out: s.Out,
SqlPackage: s.SQLPackage,
SqlDriver: s.SQLDriver,
OutputDbFileName: s.OutputDBFileName,
OutputBatchFileName: s.OutputBatchFileName,
OutputModelsFileName: s.OutputModelsFileName,
Expand Down
2 changes: 2 additions & 0 deletions internal/codegen/golang/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const (
SQLDriverLibPQ
)

const SQLDriverGoSQLDriverMySQL = "github.com/go-sql-driver/mysql"

func parseDriver(sqlPackage string) SQLDriver {
switch sqlPackage {
case SQLPackagePGXV4:
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ type SQLGo struct {
Overrides []Override `json:"overrides,omitempty" yaml:"overrides"`
Rename map[string]string `json:"rename,omitempty" yaml:"rename"`
SQLPackage string `json:"sql_package" yaml:"sql_package"`
SQLDriver string `json:"sql_driver" yaml:"sql_driver"`
OutputBatchFileName string `json:"output_batch_file_name,omitempty" yaml:"output_batch_file_name"`
OutputDBFileName string `json:"output_db_file_name,omitempty" yaml:"output_db_file_name"`
OutputModelsFileName string `json:"output_models_file_name,omitempty" yaml:"output_models_file_name"`
Expand Down
2 changes: 2 additions & 0 deletions internal/config/v_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type v1PackageSettings struct {
EmitAllEnumValues bool `json:"emit_all_enum_values,omitempty" yaml:"emit_all_enum_values"`
JSONTagsCaseStyle string `json:"json_tags_case_style,omitempty" yaml:"json_tags_case_style"`
SQLPackage string `json:"sql_package" yaml:"sql_package"`
SQLDriver string `json:"sql_driver" yaml:"sql_driver"`
Overrides []Override `json:"overrides" yaml:"overrides"`
OutputBatchFileName string `json:"output_batch_file_name,omitempty" yaml:"output_batch_file_name"`
OutputDBFileName string `json:"output_db_file_name,omitempty" yaml:"output_db_file_name"`
Expand Down Expand Up @@ -151,6 +152,7 @@ func (c *V1GenerateSettings) Translate() Config {
Package: pkg.Name,
Out: pkg.Path,
SQLPackage: pkg.SQLPackage,
SQLDriver: pkg.SQLDriver,
Overrides: pkg.Overrides,
JSONTagsCaseStyle: pkg.JSONTagsCaseStyle,
OutputBatchFileName: pkg.OutputBatchFileName,
Expand Down
330 changes: 170 additions & 160 deletions internal/plugin/codegen.pb.go

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions internal/plugin/codegen_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions protos/plugin/codegen.proto
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ message GoCode
string package = 12;
string out = 13;
string sql_package = 14;
string sql_driver = 25;
string output_db_file_name = 15;
string output_models_file_name = 16;
string output_querier_file_name = 17;
Expand Down

0 comments on commit d6560ce

Please sign in to comment.