From: <cin...@us...> - 2010-06-30 19:54:40
|
Revision: 51304 http://firebird.svn.sourceforge.net/firebird/?rev=51304&view=rev Author: cincura_net Date: 2010-06-30 19:54:34 +0000 (Wed, 30 Jun 2010) Log Message: ----------- DNET-124, DNET-328 Modified Paths: -------------- NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version10/XdrStream.cs NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Common/DbValue.cs NETProvider/trunk/NETProvider/source/FirebirdSql/Data/FirebirdClient/FbCommand.cs NETProvider/trunk/NETProvider/source/FirebirdSql/Data/FirebirdClient/FbParameter.cs Modified: NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version10/XdrStream.cs =================================================================== --- NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version10/XdrStream.cs 2010-06-30 08:55:16 UTC (rev 51303) +++ NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Client/Managed/Version10/XdrStream.cs 2010-06-30 19:54:34 UTC (rev 51304) @@ -673,8 +673,7 @@ if ((param.Length % param.Charset.BytesPerCharacter) == 0 && svalue.Length > param.CharCount) { - //throw new IscException(IscCodes.isc_arith_except); - svalue = svalue.Substring(0, param.CharCount); + throw new IscException(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation }); } this.WriteOpaque(param.Charset.GetBytes(svalue), param.Length); @@ -693,8 +692,7 @@ if ((param.Length % param.Charset.BytesPerCharacter) == 0 && svalue.Length > param.CharCount) { - //throw new IscException(IscCodes.isc_arith_except); - svalue = svalue.Substring(0, param.CharCount); + throw new IscException(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation }); } byte[] data = param.Charset.GetBytes(svalue); Modified: NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Common/DbValue.cs =================================================================== --- NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Common/DbValue.cs 2010-06-30 08:55:16 UTC (rev 51303) +++ NETProvider/trunk/NETProvider/source/FirebirdSql/Data/Common/DbValue.cs 2010-06-30 19:54:34 UTC (rev 51304) @@ -223,8 +223,8 @@ if ((this.Field.Length % this.Field.Charset.BytesPerCharacter) == 0 && svalue.Length > this.Field.CharCount) - { - throw new IscException(IscCodes.isc_arith_except); + { + throw new IscException(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation }); } byte[] buffer = new byte[this.Field.Length]; @@ -251,8 +251,8 @@ if ((this.Field.Length % this.Field.Charset.BytesPerCharacter) == 0 && svalue.Length > this.Field.CharCount) - { - throw new IscException(IscCodes.isc_arith_except); + { + throw new IscException(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation }); } byte[] sbuffer = this.Field.Charset.GetBytes(svalue); Modified: NETProvider/trunk/NETProvider/source/FirebirdSql/Data/FirebirdClient/FbCommand.cs =================================================================== --- NETProvider/trunk/NETProvider/source/FirebirdSql/Data/FirebirdClient/FbCommand.cs 2010-06-30 08:55:16 UTC (rev 51303) +++ NETProvider/trunk/NETProvider/source/FirebirdSql/Data/FirebirdClient/FbCommand.cs 2010-06-30 19:54:34 UTC (rev 51304) @@ -942,7 +942,7 @@ Charset charset = this.connection.InnerConnection.Database.Charset; // Check the parameter character set - if (parameter.Charset == FbCharset.Octets && !(parameter.Value is byte[])) + if (parameter.Charset == FbCharset.Octets && !(parameter.InternalValue is byte[])) { throw new InvalidOperationException("Value for char octets fields should be a byte array"); } @@ -1047,7 +1047,7 @@ if (index != -1) { - if (this.Parameters[index].Value == DBNull.Value || this.Parameters[index].Value == null) + if (this.Parameters[index].InternalValue == DBNull.Value || this.Parameters[index].InternalValue == null) { this.statement.Parameters[i].NullFlag = -1; this.statement.Parameters[i].Value = DBNull.Value; @@ -1067,7 +1067,7 @@ case DbDataType.Binary: { BlobBase blob = this.statement.CreateBlob(); - blob.Write((byte[])this.Parameters[index].Value); + blob.Write((byte[])this.Parameters[index].InternalValue); this.statement.Parameters[i].Value = blob.Id; } break; @@ -1075,10 +1075,10 @@ case DbDataType.Text: { BlobBase blob = this.statement.CreateBlob(); - if (this.Parameters[index].Value.GetType() == typeof(byte[])) - blob.Write((byte[])this.Parameters[index].Value); + if (this.Parameters[index].InternalValue.GetType() == typeof(byte[])) + blob.Write((byte[])this.Parameters[index].InternalValue); else - blob.Write((string)this.Parameters[index].Value); + blob.Write((string)this.Parameters[index].InternalValue); this.statement.Parameters[i].Value = blob.Id; } break; @@ -1099,22 +1099,22 @@ } this.statement.Parameters[i].ArrayHandle.Handle = 0; - this.statement.Parameters[i].ArrayHandle.Write((System.Array)this.Parameters[index].Value); + this.statement.Parameters[i].ArrayHandle.Write((System.Array)this.Parameters[index].InternalValue); this.statement.Parameters[i].Value = this.statement.Parameters[i].ArrayHandle.Handle; } break; case DbDataType.Guid: - if (!(this.Parameters[index].Value is Guid) && - !(this.Parameters[index].Value is byte[])) + if (!(this.Parameters[index].InternalValue is Guid) && + !(this.Parameters[index].InternalValue is byte[])) { throw new InvalidOperationException("Incorrect Guid value."); } - this.statement.Parameters[i].Value = this.Parameters[index].Value; + this.statement.Parameters[i].Value = this.Parameters[index].InternalValue; break; default: - this.statement.Parameters[i].Value = this.Parameters[index].Value; + this.statement.Parameters[i].Value = this.Parameters[index].InternalValue; break; } } @@ -1133,7 +1133,7 @@ if (this.parameters != null) foreach (FbParameter item in this.parameters) { - System.Diagnostics.Debug.WriteLine(string.Format("Name:{0} \t Type:{1} \t Value:{2}", item.InternalParameterName, item.FbDbType, item.Value)); + System.Diagnostics.Debug.WriteLine(string.Format("Name:{0} \t Type:{1} \t Value:{2}", item.InternalParameterName, item.FbDbType, item.InternalValue)); } #endif Modified: NETProvider/trunk/NETProvider/source/FirebirdSql/Data/FirebirdClient/FbParameter.cs =================================================================== --- NETProvider/trunk/NETProvider/source/FirebirdSql/Data/FirebirdClient/FbParameter.cs 2010-06-30 08:55:16 UTC (rev 51303) +++ NETProvider/trunk/NETProvider/source/FirebirdSql/Data/FirebirdClient/FbParameter.cs 2010-06-30 19:54:34 UTC (rev 51304) @@ -48,7 +48,6 @@ private object value; private string parameterName; private string sourceColumn; - private bool isTypeSet; #endregion @@ -73,6 +72,7 @@ set { this.size = value; + this.IsSizeSet = true; // Hack for Clob parameters if (value == 2147483647 && @@ -148,7 +148,7 @@ set { this.fbDbType = value; - this.isTypeSet = true; + this.IsTypeSet = true; } } @@ -174,7 +174,7 @@ this.value = value; - if (!this.isTypeSet) + if (!this.IsTypeSet) { this.SetFbDbType(value); } @@ -235,18 +235,34 @@ { get { - if (!String.IsNullOrEmpty(this.parameterName) && !this.parameterName.StartsWith("@")) + if (!string.IsNullOrEmpty(this.parameterName) && !this.parameterName.StartsWith("@")) { - return String.Format("@{0}", this.ParameterName); + return string.Format("@{0}", this.ParameterName); } return this.ParameterName; } } - internal bool IsTypeSet + internal bool IsTypeSet { get; private set; } + + internal bool IsSizeSet { get; private set; } + + internal object InternalValue { - get { return this.isTypeSet; } + get + { + if (this.IsSizeSet) + { + string svalue = (this.value as string); + if (svalue != null) + return svalue.Substring(0, Math.Min(this.size, svalue.Length)); + else + return this.value; + } + + return this.value; + } } #endregion This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |