Skip to content

Commit

Permalink
Add support for DATABASE_URL values with mariadb schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Malax committed Feb 19, 2025
1 parent 28ff44d commit 21a6543
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

* The buildpack output will now explicitly mention the installed OpenJDK version instead of displaying only the major version. ([#339](https://github.com/heroku/heroku-buildpack-jvm-common/pull/339)

### Added

* Support for `DATABASE_URL` values that use the `mariadb` schema. ([#000](https://github.com/heroku/heroku-buildpack-jvm-common/pull/000)

## [v159] - 2025-02-17

### Changed
Expand Down
3 changes: 3 additions & 0 deletions opt/jdbc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ set_jdbc_url() {
"mysql")
modified_schema="jdbc:mysql"
;;
"mariadb")
modified_schema="jdbc:mariadb"
;;
*)
# We don't handle database URLs that aren't mysql or postgres.
# But we also don't consider this an error and silently exit.
Expand Down
17 changes: 17 additions & 0 deletions test/jdbc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,23 @@ testMySQLDatabaseEnvVar() {
)
}

testMariaDBDatabaseEnvVar() {
(
set -e # Exit subshell after failed command, important to make multi-assert tests work properly

# Circle CI sets this environment variable. It causes trouble since the JDBC code checks this variable to see if it
# is running on Heroku CI and generates different urls in such cases, causing some tests to fail.
unset CI

export DATABASE_URL="mariadb://foo:bar@ec2-0-0-0-0:5432/abc123?reconnect=true"

# shellcheck disable=SC1090
source "$JDBC_SCRIPT_LOCATION"

assertEquals "jdbc:mariadb://ec2-0-0-0-0:5432/abc123?password=bar&reconnect=true&user=foo" "$JDBC_DATABASE_URL"
)
}

testThirdPartyDatabaseUrls() {
(
set -e # Exit subshell after failed command, important to make multi-assert tests work properly
Expand Down

0 comments on commit 21a6543

Please sign in to comment.