Skip to content

Commit

Permalink
Allow sql_package: "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 20, 2023
1 parent e99f1db commit 506a839
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions internal/codegen/golang/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ package golang
type SQLDriver int

const (
SQLPackagePGXV4 string = "pgx/v4"
SQLPackagePGXV5 string = "pgx/v5"
SQLPackageStandard string = "database/sql"
SQLPackagePGXV4 string = "pgx/v4"
SQLPackagePGXV5 string = "pgx/v5"
SQLPackageGoSqlDriverMySQL string = "go-sql-driver/mysql"
SQLPackageStandard string = "database/sql"
)

const (
SQLDriverPGXV4 SQLDriver = iota
SQLDriverPGXV5
SQLDriverGoSqlDriverMySQL
SQLDriverLibPQ
)

Expand All @@ -20,6 +22,8 @@ func parseDriver(sqlPackage string) SQLDriver {
return SQLDriverPGXV4
case SQLPackagePGXV5:
return SQLDriverPGXV5
case SQLPackageGoSqlDriverMySQL:
return SQLDriverGoSqlDriverMySQL
default:
return SQLDriverLibPQ
}
Expand All @@ -35,7 +39,18 @@ func (d SQLDriver) Package() string {
return SQLPackagePGXV4
case SQLDriverPGXV5:
return SQLPackagePGXV5
case SQLDriverGoSqlDriverMySQL:
return SQLPackageGoSqlDriverMySQL
default:
return SQLPackageStandard
}
}

func (d SQLDriver) UsesStandard() bool {
switch d {
case SQLDriverPGXV4, SQLDriverPGXV5:
return false
default:
return true
}
}

0 comments on commit 506a839

Please sign in to comment.