Skip to content

Commit fe1b6cb

Browse files
committed
NH-2408 - MsSql2000Dialect.LockHintAppender correct handle table names with explicit catalog name but without schema name in union subclasses
1 parent d98a279 commit fe1b6cb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/NHibernate.Test/DialectTest/LockHintAppenderFixture.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ public void ShouldHandleExplicitSchemasAndDbNames()
8080
Assert.That(result.ToString(), Is.EqualTo(expectedQuery));
8181
}
8282

83+
[Test]
84+
public void ShouldHandleExplicitDbNameWithoutSchemaName()
85+
{
86+
const string expectedQuery =
87+
"select Id, Name from (select Id, Name FROM nhibernate..Employee with (updlock, rowlock) union all select Id, Name from Manager with (updlock, rowlock)) as person";
88+
89+
var result = _appender.AppendLockHint(new SqlString(expectedQuery.Replace(MsSql2000LockHint, string.Empty)));
90+
Assert.That(result.ToString(), Is.EqualTo(expectedQuery));
91+
}
92+
8393
[Test]
8494
public void ShouldHandleExplicitSchemasAndDbNamesWithSpacesBetweenNameParts()
8595
{

src/NHibernate/Dialect/MsSql2000Dialect.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ public struct LockHintAppender
523523
private const string EscapedNameRegex = @"\[([^\]]|\]\])+\]";
524524
private const string NameRegex = "(" + UnescapedNameRegex + "|" + EscapedNameRegex + ")";
525525
private const string NameSeparatorRegex = @"\s*\.\s*";
526-
private const string FromTableNameRegex = @"from\s+(" + NameRegex + NameSeparatorRegex + "){0,2}" + NameRegex;
526+
private const string FromTableNameRegex = @"from\s+(" + NameRegex + "?" + NameSeparatorRegex + "){0,2}" + NameRegex;
527527

528528
private static readonly Regex FromClauseTableNameRegex = new Regex(FromTableNameRegex, RegexOptions.IgnoreCase | RegexOptions.Multiline);
529529

0 commit comments

Comments
 (0)