HHH-11915 - DatabaseMetaData#getIndexInfo can return column names enclosed in quotes on PostgresPlus

This commit is contained in:
Andrea Boriero 2017-08-08 11:05:50 +02:00 committed by Gail Badner
parent fd2dab3297
commit 65b5e6445b
2 changed files with 22 additions and 5 deletions

View File

@ -14,19 +14,26 @@ import org.hibernate.internal.util.StringHelper;
* @author Andrea Boriero * @author Andrea Boriero
*/ */
public class DatabaseIdentifier extends Identifier { public class DatabaseIdentifier extends Identifier {
protected DatabaseIdentifier(String text) {
super( text );
}
/** /**
* Constructs a datatabase identifier instance. * Constructs a datatabase identifier instance.
* *
* @param text The identifier text. * @param text The identifier text.
*/ */
public DatabaseIdentifier(String text) {
super( text, false );
}
public static DatabaseIdentifier toIdentifier(String text) { public static DatabaseIdentifier toIdentifier(String text) {
if ( StringHelper.isEmpty( text ) ) { if ( StringHelper.isEmpty( text ) ) {
return null; return null;
} }
return new DatabaseIdentifier( text ); else if ( isQuoted( text ) ) {
// exclude the quotes from text
final String unquotedtext = text.substring( 1, text.length() - 1 );
return new DatabaseIdentifier( unquotedtext );
}
else {
return new DatabaseIdentifier( text );
}
} }
} }

View File

@ -113,6 +113,16 @@ public class Identifier implements Comparable<Identifier> {
this.isQuoted = quoted; this.isQuoted = quoted;
} }
/**
* Constructs an unquoted identifier instance.
*
* @param text The identifier text.
*/
protected Identifier(String text) {
this.text = text;
this.isQuoted = false;
}
/** /**
* Get the identifiers name (text) * Get the identifiers name (text)
* *