@@ -161,7 +161,9 @@ protected override void InitializeParameter(DbParameter dbParam, string name, Sq
161
161
{
162
162
case DbType . AnsiString :
163
163
case DbType . AnsiStringFixedLength :
164
- dbParam . Size = IsAnsiText ( dbParam , sqlType ) ? MsSql2000Dialect . MaxSizeForAnsiClob : MsSql2000Dialect . MaxSizeForLengthLimitedAnsiString ;
164
+ dbParam . Size = IsAnsiText ( dbParam , sqlType )
165
+ ? MsSql2000Dialect . MaxSizeForAnsiClob
166
+ : IsChar ( dbParam , sqlType ) ? sqlType . Length : MsSql2000Dialect . MaxSizeForLengthLimitedAnsiString ;
165
167
break ;
166
168
case DbType . Binary :
167
169
dbParam . Size = IsBlob ( dbParam , sqlType ) ? MsSql2000Dialect . MaxSizeForBlob : MsSql2000Dialect . MaxSizeForLengthLimitedBinary ;
@@ -174,7 +176,9 @@ protected override void InitializeParameter(DbParameter dbParam, string name, Sq
174
176
break ;
175
177
case DbType . String :
176
178
case DbType . StringFixedLength :
177
- dbParam . Size = IsText ( dbParam , sqlType ) ? MsSql2000Dialect . MaxSizeForClob : MsSql2000Dialect . MaxSizeForLengthLimitedString ;
179
+ dbParam . Size = IsText ( dbParam , sqlType )
180
+ ? MsSql2000Dialect . MaxSizeForClob
181
+ : IsChar ( dbParam , sqlType ) ? sqlType . Length : MsSql2000Dialect . MaxSizeForLengthLimitedString ;
178
182
break ;
179
183
case DbType . DateTime2 :
180
184
dbParam . Size = MsSql2000Dialect . MaxDateTime2 ;
@@ -283,6 +287,17 @@ protected static bool IsBlob(DbParameter dbParam, SqlType sqlType)
283
287
return ( sqlType is BinaryBlobSqlType ) || ( ( DbType . Binary == dbParam . DbType ) && sqlType . LengthDefined && ( sqlType . Length > MsSql2000Dialect . MaxSizeForLengthLimitedBinary ) ) ;
284
288
}
285
289
290
+ /// <summary>
291
+ /// Interprets if a parameter is a character (for the purposes of setting its default size)
292
+ /// </summary>
293
+ /// <param name="dbParam">The parameter</param>
294
+ /// <param name="sqlType">The <see cref="SqlType" /> of the parameter</param>
295
+ /// <returns>True, if the parameter should be interpreted as a character, otherwise False</returns>
296
+ protected static bool IsChar ( DbParameter dbParam , SqlType sqlType )
297
+ {
298
+ return ( DbType . StringFixedLength == dbParam . DbType || DbType . StringFixedLength == dbParam . DbType ) &&
299
+ sqlType . LengthDefined && sqlType . Length == 1 ;
300
+ }
286
301
public override IResultSetsCommand GetResultSetsCommand ( ISessionImplementor session )
287
302
{
288
303
return new BasicResultSetsCommand ( session ) ;
0 commit comments