-
Notifications
You must be signed in to change notification settings - Fork 3.6k
HHH-14584 Allow PhysicalNamingStrategy implementations to detect when a name is implicit or explicit #10366
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
base: main
Are you sure you want to change the base?
Conversation
Identifier logicalName = null; | ||
if ( name != null ) { | ||
logicalName = getDatabase().toIdentifier( name ); | ||
logicalName.setExplicit( isExplicit ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identifier logicalName = null; | |
if ( name != null ) { | |
logicalName = getDatabase().toIdentifier( name ); | |
logicalName.setExplicit( isExplicit ); | |
} | |
final Identifier logicalName; | |
if ( name == null ) { | |
logicalName = null | |
} | |
else { | |
logicalName = getDatabase().toIdentifier( name ); | |
logicalName.setExplicit( isExplicit ); | |
} |
if ( applyNamingStrategy ) { | ||
final Database database = getDatabase(); | ||
Identifier identifier = database.toIdentifier( columnName ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identifier identifier = database.toIdentifier( columnName ); | |
final Identifier identifier = database.toIdentifier( columnName ); |
@@ -1773,7 +1773,10 @@ public MetadataBuildingContext getBuildingContext() { | |||
|
|||
@Override | |||
public Identifier handleExplicitName(String explicitName, MetadataBuildingContext buildingContext) { | |||
return jdbcEnvironment( buildingContext ).getIdentifierHelper().toIdentifier( explicitName ); | |||
Identifier identifier = jdbcEnvironment( buildingContext ).getIdentifierHelper() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identifier identifier = jdbcEnvironment( buildingContext ).getIdentifierHelper() | |
final Identifier identifier = jdbcEnvironment( buildingContext ).getIdentifierHelper() |
@@ -23,6 +23,7 @@ | |||
public class Identifier implements Comparable<Identifier> { | |||
private final String text; | |||
private final boolean isQuoted; | |||
private boolean isExplicit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would probably be better to keep Identifier
is a completely immutable object, and overload Database.toIdentifier()
to accept isExplicit
is a parameter.
@@ -352,10 +352,12 @@ private static QualifiedName sequenceName( | |||
IdentifierHelper identifierHelper) { | |||
if ( isNotEmpty( explicitSequenceName ) ) { | |||
// we have an explicit name, use it | |||
return explicitSequenceName.contains(".") | |||
QualifiedNameParser.NameParts nameParts = explicitSequenceName.contains( "." ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QualifiedNameParser.NameParts nameParts = explicitSequenceName.contains( "." ) | |
final QualifiedNameParser.NameParts nameParts = explicitSequenceName.contains( "." ) |
… a name is implicit or explicit
f3a867d
to
f2c18e7
Compare
In HHH-14584, an additional field was requested in
Identifier
to indicate explicit namings of columns.This would allow more possibilies in a custom
PhysicalNamingStrategy
.As
PhysicalNamingStrategy
also provides methods for sequences and tables, this PR also implements handling explicit namings of both of them.However, I did not provide it for schemas and catalogs.
Many thanks in advance for feedback, comments and change requests. :)
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.
https://hibernate.atlassian.net/browse/HHH-14584