Skip to content

Commit

Permalink
Merge pull request #439 from symfony-cli/mariadb-docker-version-fix
Browse files Browse the repository at this point in the history
Fix MariaDB version when using Docker
  • Loading branch information
fabpot committed Feb 14, 2024
2 parents 095d4b6 + fefaff9 commit 57dc589
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions envs/envs.go
Expand Up @@ -24,6 +24,7 @@ import (
"fmt"
"os"
"path/filepath"
"regexp"
"strconv"
"strings"

Expand Down Expand Up @@ -186,8 +187,9 @@ func extractRelationshipsEnvs(env Environment) Envs {
// Docker support
if v, ok := endpoint["version"]; ok {
values[versionKey] = v.(string)
if strings.HasPrefix(values[versionKey], "1:") {
values[versionKey] = values[versionKey][2:]

if matches := regexp.MustCompile("^\\d:(\\d+\\.\\d+\\.\\d+).maria").FindStringSubmatch(values[versionKey]); matches != nil {
values[versionKey] = fmt.Sprintf("%s-MariaDB", matches[1])
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion envs/envs_test.go
Expand Up @@ -134,7 +134,7 @@ func (s *ScenvSuite) TestDockerDatabaseURLs(c *C) {
}

rels := extractRelationshipsEnvs(env)
c.Assert(rels["MYSQL_URL"], Equals, "mysql://root:!ChangeMe!@127.0.0.1:56614/root?sslmode=disable&charset=utf8mb4&serverVersion=10.0.38+maria-1~xenial")
c.Assert(rels["MYSQL_URL"], Equals, "mysql://root:!ChangeMe!@127.0.0.1:56614/root?sslmode=disable&charset=utf8mb4&serverVersion=10.0.38-MariaDB")
c.Assert(rels["POSTGRESQL_URL"], Equals, "postgres://main:main@127.0.0.1:63574/main?sslmode=disable&charset=utf8&serverVersion=13.13")
}

Expand Down

0 comments on commit 57dc589

Please sign in to comment.