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 378ecab
Show file tree
Hide file tree
Showing 7 changed files with 228 additions and 164 deletions.
1 change: 1 addition & 0 deletions internal/cmd/shim.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func pluginGoCode(s config.SQLGo) *plugin.GoCode {
EmitAllEnumValues: s.EmitAllEnumValues,
JsonTagsCaseStyle: s.JSONTagsCaseStyle,
Package: s.Package,
Driver: s.Driver,
Out: s.Out,
SqlPackage: s.SQLPackage,
OutputDbFileName: s.OutputDBFileName,
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
337 changes: 173 additions & 164 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 @@ -82,6 +82,7 @@ message GoCode
bool emit_methods_with_db_argument = 10;
string json_tags_case_style = 11;
string package = 12;
string driver = 25;
string out = 13;
string sql_package = 14;
string output_db_file_name = 15;
Expand Down

0 comments on commit 378ecab

Please sign in to comment.