Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for DATABASE_URL values with mariadb scheme #341

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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` scheme. ([#341](https://github.com/heroku/heroku-buildpack-jvm-common/pull/341)

## [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
2 changes: 1 addition & 1 deletion test/spec/java_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
'.profile.d/jvmcommon.sh' => 'f4727529254d7e5bd9f7de2ec110bffe',
'.profile.d/default-proc-warning.sh' => 'bb7cd4e1747e2a0c0e9a7137e84d3cf5',
'.profile.d/heroku-jvm-metrics.sh' => '9f48b384bc3d9161e45e15906793b191',
'.profile.d/jdbc.sh' => '7a5ce665af22b057c027b1080d2df3d3',
'.profile.d/jdbc.sh' => '7a2abf4a9aaec0b98e3681fbc2d4d215',
'.profile.d/jvm-redis.sh' => '7873896b3392a91b35af7dcfad115d6b',
'.heroku/with_jmap/bin/java' => 'adc9d1e5abbc1b39d56dc37ce3e26ab8',
'.heroku/with_jmap_and_jstack/bin/java' => '5dbd18ed94a0b1f3542ab100f88fd47d',
Expand Down