@@ -30,30 +30,31 @@ protected override IList Mappings
30
30
}
31
31
}
32
32
33
- protected override bool AppliesTo ( Dialect . Dialect dialect )
34
- {
35
- // this test only works where the driver has set an explicit length on the IDbDataParameter
36
- return dialect is MsSql2008Dialect ;
37
- }
38
33
39
34
[ Test ]
40
35
public void NhThrowsOnTooLong ( )
41
36
{
37
+ if ( ! ( Dialect is MsSql2008Dialect ) )
38
+ Assert . Ignore (
39
+ "This test only works (and is only relevant) " +
40
+ "where the driver has set an explicit length " +
41
+ "on the IDbDataParameter." ) ;
42
+
42
43
int maxStringLength = 4000 ;
43
- PropertyValueException ex = Assert . Throws < PropertyValueException > ( ( ) =>
44
+ PropertyValueException ex = Assert . Throws < PropertyValueException > (
45
+ ( ) =>
44
46
{
45
47
using ( ISession s = OpenSession ( ) )
46
48
{
47
- StringClass b = new StringClass ( ) ;
48
- b . LongStringValue = new string ( 'x' , maxStringLength + 1 ) ;
49
+ StringClass b = new StringClass { LongStringValue = new string ( 'x' , maxStringLength + 1 ) } ;
49
50
s . Save ( b ) ;
50
51
s . Flush ( ) ;
51
52
}
52
53
} ) ;
53
54
54
- Assert . That ( ex . Message , Iz . EqualTo ( "Error dehydrating property value for NHibernate.Test.TypesTest.StringClass.LongStringValue" ) ) ;
55
- Assert . That ( ex . InnerException , Iz . TypeOf < HibernateException > ( ) ) ;
56
- Assert . That ( ex . InnerException . Message , Iz . EqualTo ( "The length of the string value exceeds the length configured in the mapping/parameter." ) ) ;
55
+ Assert . That ( ex . Message , Is . EqualTo ( "Error dehydrating property value for NHibernate.Test.TypesTest.StringClass.LongStringValue" ) ) ;
56
+ Assert . That ( ex . InnerException , Is . TypeOf < HibernateException > ( ) ) ;
57
+ Assert . That ( ex . InnerException . Message , Is . EqualTo ( "The length of the string value exceeds the length configured in the mapping/parameter." ) ) ;
57
58
}
58
59
59
60
[ Test ]
@@ -65,8 +66,7 @@ public void DbThrowsOnTooLong()
65
66
{
66
67
using ( ISession s = OpenSession ( ) )
67
68
{
68
- StringClass b = new StringClass ( ) ;
69
- b . StringValue = "0123456789a" ;
69
+ StringClass b = new StringClass { StringValue = "0123456789a" } ;
70
70
s . Save ( b ) ;
71
71
s . Flush ( ) ;
72
72
}
@@ -82,7 +82,7 @@ public void DbThrowsOnTooLong()
82
82
[ Test ]
83
83
public void CriteriaLikeParameterCanExceedColumnSize ( )
84
84
{
85
- if ( ! ( sessions . ConnectionProvider . Driver is SqlClientDriver ) )
85
+ if ( sessions . ConnectionProvider . Driver is OdbcDriver )
86
86
Assert . Ignore ( "This test fails against the ODBC driver. The driver would need to be override to allow longer parameter sizes than the column." ) ;
87
87
88
88
using ( ISession s = OpenSession ( ) )
@@ -103,7 +103,7 @@ public void CriteriaLikeParameterCanExceedColumnSize()
103
103
[ Test ]
104
104
public void HqlLikeParameterCanExceedColumnSize ( )
105
105
{
106
- if ( ! ( sessions . ConnectionProvider . Driver is SqlClientDriver ) )
106
+ if ( sessions . ConnectionProvider . Driver is OdbcDriver )
107
107
Assert . Ignore ( "This test fails against the ODBC driver. The driver would need to be override to allow longer parameter sizes than the column." ) ;
108
108
109
109
using ( ISession s = OpenSession ( ) )
@@ -120,5 +120,54 @@ public void HqlLikeParameterCanExceedColumnSize()
120
120
Assert . That ( aaItems . Count , Is . EqualTo ( 2 ) ) ;
121
121
}
122
122
}
123
+
124
+
125
+ [ Test ]
126
+ public void CriteriaEqualityParameterCanExceedColumnSize ( )
127
+ {
128
+ if ( sessions . ConnectionProvider . Driver is OdbcDriver )
129
+ Assert . Ignore ( "This test fails against the ODBC driver. The driver would need to be override to allow longer parameter sizes than the column." ) ;
130
+
131
+ // We should be able to query a column with a value longer than
132
+ // the specified column size, to avoid tedious exceptions.
133
+
134
+ using ( ISession s = OpenSession ( ) )
135
+ using ( s . BeginTransaction ( ) )
136
+ {
137
+ s . Save ( new StringClass { Id = 1 , StringValue = "AAAAAAAAAB" } ) ;
138
+ s . Save ( new StringClass { Id = 2 , StringValue = "BAAAAAAAAA" } ) ;
139
+
140
+ var aaItems =
141
+ s . CreateCriteria < StringClass > ( )
142
+ . Add ( Restrictions . Eq ( "StringValue" , "AAAAAAAAABx" ) )
143
+ . List ( ) ;
144
+
145
+ Assert . That ( aaItems . Count , Is . EqualTo ( 0 ) ) ;
146
+ }
147
+ }
148
+
149
+ [ Test ]
150
+ public void HqlEqualityParameterCanExceedColumnSize ( )
151
+ {
152
+ if ( sessions . ConnectionProvider . Driver is OdbcDriver )
153
+ Assert . Ignore ( "This test fails against the ODBC driver. The driver would need to be override to allow longer parameter sizes than the column." ) ;
154
+
155
+ // We should be able to query a column with a value longer than
156
+ // the specified column size, to avoid tedious exceptions.
157
+
158
+ using ( ISession s = OpenSession ( ) )
159
+ using ( s . BeginTransaction ( ) )
160
+ {
161
+ s . Save ( new StringClass { Id = 1 , StringValue = "AAAAAAAAAB" } ) ;
162
+ s . Save ( new StringClass { Id = 2 , StringValue = "BAAAAAAAAA" } ) ;
163
+
164
+ var aaItems =
165
+ s . CreateQuery ( "from StringClass s where s.StringValue = :likeValue" )
166
+ . SetParameter ( "likeValue" , "AAAAAAAAABx" )
167
+ . List ( ) ;
168
+
169
+ Assert . That ( aaItems . Count , Is . EqualTo ( 0 ) ) ;
170
+ }
171
+ }
123
172
}
124
173
}
0 commit comments