-
Notifications
You must be signed in to change notification settings - Fork 934
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix enums used as parameter for string columns (#2622)
Special treatment of enums mapped on string columns because all reasons for checking string lengths or streamlining the length of parameters of queries on string columns to the length of the column for SQL Server are also valid for enums because they are sometimes by convention used to model the possible values of a string column * Fixes #2621
- Loading branch information
1 parent
10393df
commit e5ad951
Showing
4 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using NUnit.Framework; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH2621Enum | ||
{ | ||
public class Fixture : BugTestCase | ||
{ | ||
[Test] | ||
public void TestOk() | ||
{ | ||
using (var s = OpenSession()) | ||
using (s.BeginTransaction()) | ||
{ | ||
var query = s.CreateQuery( | ||
@"SELECT Name FROM NHibernate.Test.NHSpecificTest.GH2621Enum.ClassWithString ROOT WHERE ROOT.Kind = :kind"); | ||
query.SetParameter("kind", Kind.SomeKind); | ||
Assert.DoesNotThrow(() => query.List()); | ||
} | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/NHibernate.Test/NHSpecificTest/GH2621Enum/Mappings.hbm.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" | ||
namespace="NHibernate.Test.NHSpecificTest.GH2621Enum" | ||
assembly="NHibernate.Test" | ||
> | ||
<class name="ClassWithString" > | ||
<id name="Id"> | ||
<generator class="increment"/> | ||
</id> | ||
<property name="Name"/> | ||
<property name="Kind"/> | ||
</class> | ||
|
||
</hibernate-mapping> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace NHibernate.Test.NHSpecificTest.GH2621Enum | ||
{ | ||
public abstract class ClassWithString | ||
{ | ||
public virtual int Id { get; set; } | ||
public virtual string Name { get; set; } | ||
public virtual string Kind { get; set; } | ||
} | ||
|
||
public enum Kind | ||
{ | ||
SomeKind, | ||
SomeOtherKind | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters