Skip to content
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

fixing a truncated table name #3571

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/NHibernate.Test/DialectTest/Oracle8iDialectFixture.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NHibernate.Cfg;
using NHibernate.Cfg;
using NHibernate.Dialect;
using NHibernate.SqlCommand;
using NHibernate.Util;
Expand Down Expand Up @@ -148,5 +148,18 @@ public void CheckUnicodeWithPrefix()
}

#endregion
[Test]
public void TemporaryTableNameTruncation()
{
string temporaryTableName = new Oracle8iDialect().GenerateTemporaryTableName(
"TABLE_NAME_THAT_EXCEEDS_30_CHARACTERS");
Assert.AreEqual(
30,
temporaryTableName.Length);
Comment on lines +156 to +158
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Assert.AreEqual(
30,
temporaryTableName.Length);
Assert.That(temporaryTableName, Has.Length.EqualTo(30));

Assert.AreEqual(
"HT_TABLE_NAME_THAT_EXCEEDS_30_",
temporaryTableName
);
Comment on lines +159 to +162
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Assert.AreEqual(
"HT_TABLE_NAME_THAT_EXCEEDS_30_",
temporaryTableName
);
Assert.That(temporaryTableName, Is.EqualTo("HT_TABLE_NAME_THAT_EXCEEDS_30_"));

}
}
}
}
2 changes: 1 addition & 1 deletion src/NHibernate/Dialect/Oracle8iDialect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ public override bool SupportsTemporaryTables
public override string GenerateTemporaryTableName(String baseTableName)
{
string name = base.GenerateTemporaryTableName(baseTableName);
return name.Length > 30 ? name.Substring(1, (30) - (1)) : name;
return name.Length > 30 ? name.Substring(0, (30) - (1)) : name;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to remove -1 as well

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return name.Length > 30 ? name.Substring(0, (30) - (1)) : name;
return name.Length > 30 ? name.Substring(0, 30) : name;

}

/// <inheritdoc />
Expand Down