+
Skip to content

Use updated PostgresDatabase from Liquibase 4.32.0 #40530

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

Merged
merged 1 commit into from
Jun 24, 2025
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.keycloak.connections.jpa.updater.liquibase;

import liquibase.GlobalConfiguration;
import liquibase.database.ObjectQuotingStrategy;
import liquibase.database.core.PostgresDatabase;
import liquibase.structure.DatabaseObject;
import liquibase.structure.core.Catalog;
import liquibase.structure.core.Schema;
import liquibase.util.StringUtil;

import java.util.Locale;

/**
* Workaround for <a href="https://github.com/keycloak/keycloak/issues/39917">keycloak#39917</a>
* Remove it once Liquibase 4.32.0 is used
*/
public class UpdatedPostgresDatabase extends PostgresDatabase {

@Override
public int getPriority() {
return super.getPriority() + 1; // Always take precedence over factory PostgresDatabase
}

/**
* Use updated version present in Liquibase 4.32.0 - <a href="https://github.com/liquibase/liquibase/blob/v4.32.0/liquibase-standard/src/main/java/liquibase/database/core/PostgresDatabase.java#L300">PostgresDatabase.correctObjectName()</a>
*/
@Override
public String correctObjectName(String objectName, Class<? extends DatabaseObject> objectType) {
if ((objectName == null) || (quotingStrategy != ObjectQuotingStrategy.LEGACY)) {
return super.correctObjectName(objectName, objectType);
}
//
// Check preserve case flag for schema
//
if (objectType.equals(Schema.class) && Boolean.TRUE.equals(GlobalConfiguration.PRESERVE_SCHEMA_CASE.getCurrentValue())) {
return objectName;
}

if (objectType.equals(Catalog.class) && !StringUtil.hasLowerCase(objectName)) {
return objectName;
}

if (objectName.contains("-")
|| hasMixedCase(objectName)
|| startsWithNumeric(objectName)
|| isReservedWord(objectName)) {
return objectName;
} else {
return objectName.toLowerCase(Locale.US);
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@

org.keycloak.connections.jpa.updater.liquibase.PostgresPlusDatabase
org.keycloak.connections.jpa.updater.liquibase.UpdatedMariaDBDatabase
org.keycloak.connections.jpa.updater.liquibase.UpdatedMySqlDatabase
org.keycloak.connections.jpa.updater.liquibase.UpdatedMySqlDatabase
org.keycloak.connections.jpa.updater.liquibase.UpdatedPostgresDatabase
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private String amendH2(String jdbcUrl) {
getProperty(DatabaseOptions.DB_URL_PORT, namedProperty, "5432"),
getProperty(DatabaseOptions.DB_URL_DATABASE, namedProperty, "keycloak"),
getProperty(DatabaseOptions.DB_URL_PROPERTIES, namedProperty)),
asList("liquibase.database.core.PostgresDatabase", "org.keycloak.connections.jpa.updater.liquibase.PostgresPlusDatabase"),
asList("org.keycloak.connections.jpa.updater.liquibase.UpdatedPostgresDatabase", "org.keycloak.connections.jpa.updater.liquibase.PostgresPlusDatabase"),
"postgres"
),
MSSQL("mssql",
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载