Skip to content

Commit 378ecab

Browse files
committed
Allow sql_driver: "github.com/go-sql-driver/mysql"
In preparation of sqlc-dev#2179 for LOAD DATA LOCAL INFILE
1 parent e99f1db commit 378ecab

File tree

7 files changed

+228
-164
lines changed

7 files changed

+228
-164
lines changed

internal/cmd/shim.go

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func pluginGoCode(s config.SQLGo) *plugin.GoCode {
9696
EmitAllEnumValues: s.EmitAllEnumValues,
9797
JsonTagsCaseStyle: s.JSONTagsCaseStyle,
9898
Package: s.Package,
99+
Driver: s.Driver,
99100
Out: s.Out,
100101
SqlPackage: s.SQLPackage,
101102
OutputDbFileName: s.OutputDBFileName,

internal/codegen/golang/driver.go

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const (
1414
SQLDriverLibPQ
1515
)
1616

17+
const SQLDriverGoSQLDriverMySQL = "github.com/go-sql-driver/mysql"
18+
1719
func parseDriver(sqlPackage string) SQLDriver {
1820
switch sqlPackage {
1921
case SQLPackagePGXV4:

internal/config/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ type SQLGo struct {
135135
Overrides []Override `json:"overrides,omitempty" yaml:"overrides"`
136136
Rename map[string]string `json:"rename,omitempty" yaml:"rename"`
137137
SQLPackage string `json:"sql_package" yaml:"sql_package"`
138+
SQLDriver string `json:"sql_driver" yaml:"sql_driver"`
138139
OutputBatchFileName string `json:"output_batch_file_name,omitempty" yaml:"output_batch_file_name"`
139140
OutputDBFileName string `json:"output_db_file_name,omitempty" yaml:"output_db_file_name"`
140141
OutputModelsFileName string `json:"output_models_file_name,omitempty" yaml:"output_models_file_name"`

internal/config/v_one.go

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type v1PackageSettings struct {
3838
EmitAllEnumValues bool `json:"emit_all_enum_values,omitempty" yaml:"emit_all_enum_values"`
3939
JSONTagsCaseStyle string `json:"json_tags_case_style,omitempty" yaml:"json_tags_case_style"`
4040
SQLPackage string `json:"sql_package" yaml:"sql_package"`
41+
SQLDriver string `json:"sql_driver" yaml:"sql_driver"`
4142
Overrides []Override `json:"overrides" yaml:"overrides"`
4243
OutputBatchFileName string `json:"output_batch_file_name,omitempty" yaml:"output_batch_file_name"`
4344
OutputDBFileName string `json:"output_db_file_name,omitempty" yaml:"output_db_file_name"`
@@ -151,6 +152,7 @@ func (c *V1GenerateSettings) Translate() Config {
151152
Package: pkg.Name,
152153
Out: pkg.Path,
153154
SQLPackage: pkg.SQLPackage,
155+
SQLDriver: pkg.SQLDriver,
154156
Overrides: pkg.Overrides,
155157
JSONTagsCaseStyle: pkg.JSONTagsCaseStyle,
156158
OutputBatchFileName: pkg.OutputBatchFileName,

internal/plugin/codegen.pb.go

+173-164
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/plugin/codegen_vtproto.pb.go

+48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/plugin/codegen.proto

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ message GoCode
8282
bool emit_methods_with_db_argument = 10;
8383
string json_tags_case_style = 11;
8484
string package = 12;
85+
string driver = 25;
8586
string out = 13;
8687
string sql_package = 14;
8788
string output_db_file_name = 15;

0 commit comments

Comments
 (0)