From 65b5e6445b993d1c23c64c567b4268000b6f7bad Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Tue, 8 Aug 2017 11:05:50 +0200 Subject: [PATCH] HHH-11915 - DatabaseMetaData#getIndexInfo can return column names enclosed in quotes on PostgresPlus --- .../boot/model/naming/DatabaseIdentifier.java | 17 ++++++++++++----- .../hibernate/boot/model/naming/Identifier.java | 10 ++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/naming/DatabaseIdentifier.java b/hibernate-core/src/main/java/org/hibernate/boot/model/naming/DatabaseIdentifier.java index 6f60bb8fb0..88e70f0faf 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/naming/DatabaseIdentifier.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/naming/DatabaseIdentifier.java @@ -14,19 +14,26 @@ import org.hibernate.internal.util.StringHelper; * @author Andrea Boriero */ public class DatabaseIdentifier extends Identifier { + protected DatabaseIdentifier(String text) { + super( text ); + } + /** * Constructs a datatabase identifier instance. * * @param text The identifier text. */ - public DatabaseIdentifier(String text) { - super( text, false ); - } - public static DatabaseIdentifier toIdentifier(String text) { if ( StringHelper.isEmpty( text ) ) { 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 ); + } } } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/naming/Identifier.java b/hibernate-core/src/main/java/org/hibernate/boot/model/naming/Identifier.java index b63a6fe6ab..fafcd35635 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/naming/Identifier.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/naming/Identifier.java @@ -113,6 +113,16 @@ public class Identifier implements Comparable { 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) *