Skip to content

Commit

Permalink
Allow sql_driver: "github.com/go-sql-driver/mysql" (#2219)
Browse files Browse the repository at this point in the history
In preparation of #2179 for LOAD DATA LOCAL INFILE
  • Loading branch information
Jille authored Apr 21, 2023
1 parent c8594cb commit 0cc1aad
Show file tree
Hide file tree
Showing 10 changed files with 228 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
1 change: 1 addition & 0 deletions internal/endtoend/testdata/codegen_json/gen/codegen.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"package": "",
"out": "",
"sql_package": "",
"sql_driver": "",
"output_db_file_name": "",
"output_models_file_name": "",
"output_querier_file_name": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"package": "",
"out": "",
"sql_package": "",
"sql_driver": "",
"output_db_file_name": "",
"output_models_file_name": "",
"output_querier_file_name": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"package": "",
"out": "",
"sql_package": "",
"sql_driver": "",
"output_db_file_name": "",
"output_models_file_name": "",
"output_querier_file_name": "",
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 0cc1aad

Please sign in to comment.