Skip to content

Commit

Permalink
rename NormalizeDialectSynonyms to CanonicalDialect
Browse files Browse the repository at this point in the history
  • Loading branch information
sio4 committed Jun 4, 2022
1 parent 4949a86 commit 3d41646
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions connection_details.go
Expand Up @@ -78,7 +78,7 @@ func (cd *ConnectionDetails) withURL() error {
if dialectX.MatchString(ul) {
// Guess the dialect from the scheme
dialect := ul[:strings.Index(ul, ":")]
cd.Dialect = NormalizeDialectSynonyms(dialect)
cd.Dialect = CanonicalDialect(dialect)
} else {
return errors.New("no dialect provided, and could not guess it from URL")
}
Expand Down Expand Up @@ -125,7 +125,7 @@ func (cd *ConnectionDetails) withURL() error {
// Finalize cleans up the connection details by normalizing names,
// filling in default values, etc...
func (cd *ConnectionDetails) Finalize() error {
cd.Dialect = NormalizeDialectSynonyms(cd.Dialect)
cd.Dialect = CanonicalDialect(cd.Dialect)

if cd.Options == nil { // for safety
cd.Options = make(map[string]string)
Expand Down
2 changes: 1 addition & 1 deletion connection_instrumented.go
Expand Up @@ -39,7 +39,7 @@ func instrumentDriver(deets *ConnectionDetails, defaultDriverName string) (drive

var dr driver.Driver
var newDriverName string
switch NormalizeDialectSynonyms(driverName) {
switch CanonicalDialect(driverName) {
case nameCockroach:
fallthrough
case namePostgreSQL:
Expand Down
2 changes: 1 addition & 1 deletion match.go
Expand Up @@ -26,7 +26,7 @@ func ParseMigrationFilename(filename string) (*Match, error) {
if m[3] == "" {
dbType = "all"
} else {
dbType = NormalizeDialectSynonyms(m[3][1:])
dbType = CanonicalDialect(m[3][1:])
if !DialectSupported(dbType) {
return nil, fmt.Errorf("unsupported dialect %s", dbType)
}
Expand Down
4 changes: 2 additions & 2 deletions pop.go
Expand Up @@ -56,8 +56,8 @@ func DialectSupported(d string) bool {
return false
}

func NormalizeDialectSynonyms(dialect string) string {
d := strings.ToLower(dialect)
func CanonicalDialect(synonym string) string {
d := strings.ToLower(synonym)
if syn, ok := dialectSynonyms[d]; ok {
d = syn
}
Expand Down

0 comments on commit 3d41646

Please sign in to comment.