Skip to content

Commit a2c1f2a

Browse files
committed
NH-3998 - Alias of a column should be calculated based on a CanonicalName rather than raw name
1 parent 130d922 commit a2c1f2a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/NHibernate/Mapping/Column.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,18 @@ public string GetAlias(Dialect.Dialect dialect)
127127

128128
private string GetAlias(int maxAliasLength)
129129
{
130-
string alias = _name;
130+
var name = CanonicalName;
131+
string alias = name;
131132
string suffix = UniqueInteger.ToString() + StringHelper.Underscore;
132133

133-
int lastLetter = StringHelper.LastIndexOfLetter(_name);
134+
int lastLetter = StringHelper.LastIndexOfLetter(name);
134135
if (lastLetter == -1)
135136
{
136137
alias = "column";
137138
}
138-
else if (lastLetter < _name.Length - 1)
139+
else if (lastLetter < name.Length - 1)
139140
{
140-
alias = _name.Substring(0, lastLetter + 1);
141+
alias = name.Substring(0, lastLetter + 1);
141142
}
142143

143144
// Updated logic ported from Hibernate's fix for HHH-8073.
@@ -147,9 +148,9 @@ private string GetAlias(int maxAliasLength)
147148
// reason, the checks for "_quoted" and "rowid" looks redundant. If you remove
148149
// those checks, then the double checks for total length can be reduced to one.
149150
// But I will leave it like this for now to make it look similar. /Oskar 2016-08-20
150-
bool useRawName = _name.Length + suffix.Length <= maxAliasLength &&
151+
bool useRawName = name.Length + suffix.Length <= maxAliasLength &&
151152
!_quoted &&
152-
!StringHelper.EqualsCaseInsensitive(_name, "rowid");
153+
!StringHelper.EqualsCaseInsensitive(name, "rowid");
153154
if (!useRawName)
154155
{
155156
if (suffix.Length >= maxAliasLength)

0 commit comments

Comments
 (0)