772 Reggie Burnett 2009-10-29
- now exposing the MySqlDecimal type along with GetMySqlDecimal methods on data reader (bug #48100)
modified:
CHANGES
MySql.Data/Provider/Source/Types/MySqlDecimal.cs
MySql.Data/Provider/Source/datareader.cs
MySql.Data/Tests/Source/DataTypeTests.cs
771 Reggie Burnett 2009-10-28
- fixed unsigned types in views when used as entities (bug # 47872)
modified:
CHANGES
MySql.Data.Entity/Provider/MySql.Data.Entity.csproj
MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.0.ssdl
MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.1.ssdl
MySql.Data.Entity/Provider/Properties/SchemaDefinition-6.0.ssdl
MySql.Data.Entity/Tests/MySql.Data.Entity.Tests.csproj
MySql.Data.Entity/Tests/TestModel.Designer.cs
=== modified file 'CHANGES'
=== modified file 'CHANGES'
--- a/CHANGES 2009-10-28 15:56:50 +0000
+++ b/CHANGES 2009-10-29 21:29:54 +0000
@@ -41,7 +41,8 @@
- we are now throwing an InvalidOperationException is the TableDirect command type is used
- fixed indexes schema collection so that it still works with bad table names such as b``a`d (bug #48101)
- fixed unsigned types in views when used as entities (bug # 47872)
-
+- now exposing the MySqlDecimal type along with GetMySqlDecimal methods on data reader (bug #48100)
+
Version 6.0.4
- fixed regression where using stored procs with datasets (bug #44460)
- fixed compilation under VS 2005 (bug #44822)
=== modified file 'MySql.Data/Provider/Source/Types/MySqlDecimal.cs'
--- a/MySql.Data/Provider/Source/Types/MySqlDecimal.cs 2009-04-21 18:02:13 +0000
+++ b/MySql.Data/Provider/Source/Types/MySqlDecimal.cs 2009-10-29 21:29:54 +0000
@@ -26,21 +26,21 @@
namespace MySql.Data.Types
{
- internal struct MySqlDecimal : IMySqlValue
+ public struct MySqlDecimal : IMySqlValue
{
private byte precision;
private byte scale;
- private Decimal mValue;
+ private string mValue;
private bool isNull;
- public MySqlDecimal(bool isNull)
+ internal MySqlDecimal(bool isNull)
{
this.isNull = isNull;
- mValue = 0;
+ mValue = null;
precision = scale = 0;
}
- public MySqlDecimal(decimal val)
+ internal MySqlDecimal(string val)
{
this.isNull = false;
precision = scale = 0;
@@ -84,9 +84,19 @@
public decimal Value
{
- get { return mValue; }
+ get { return Convert.ToDecimal(mValue); }
}
+ public double ToDouble()
+ {
+ return Double.Parse(mValue);
+ }
+
+ public override string ToString()
+ {
+ return mValue;
+ }
+
Type IMySqlValue.SystemType
{
get { return typeof(decimal); }
@@ -112,18 +122,12 @@
if (nullVal)
return new MySqlDecimal(true);
+ string s = String.Empty;
if (length == -1)
- {
- string s = packet.ReadLenString();
- return new MySqlDecimal(Decimal.Parse(s,
- CultureInfo.InvariantCulture));
- }
- else
- {
- string s = packet.ReadString(length);
- return new MySqlDecimal(Decimal.Parse(s,
- CultureInfo.InvariantCulture));
- }
+ s = packet.ReadLenString();
+ else
+ s = packet.ReadString(length);
+ return new MySqlDecimal(s);
}
void IMySqlValue.SkipValue(MySqlPacket packet)
=== modified file 'MySql.Data/Provider/Source/datareader.cs'
--- a/MySql.Data/Provider/Source/datareader.cs 2009-08-10 18:03:52 +0000
+++ b/MySql.Data/Provider/Source/datareader.cs 2009-10-29 21:29:54 +0000
@@ -419,6 +419,16 @@
return dt.GetDateTime();
}
+ public MySqlDecimal GetMySqlDecimal(string column)
+ {
+ return GetMySqlDecimal(GetOrdinal(column));
+ }
+
+ public MySqlDecimal GetMySqlDecimal(int i)
+ {
+ return (MySqlDecimal)GetFieldValue(i, false);
+ }
+
/// <include file='docs/MySqlDataReader.xml' path='docs/GetDecimalS/*'/>
public Decimal GetDecimal(string column)
{
=== modified file 'MySql.Data/Tests/Source/DataTypeTests.cs'
--- a/MySql.Data/Tests/Source/DataTypeTests.cs 2009-07-28 13:10:23 +0000
+++ b/MySql.Data/Tests/Source/DataTypeTests.cs 2009-10-29 21:29:54 +0000
@@ -894,5 +894,34 @@
Assert.AreEqual(16, size);
}
}
+
+ /// <summary>
+ /// Bug #48100 Impossible to retrieve decimal value if it doesn't fit into .Net System.Decimal
+ /// </summary>
+ [Test]
+ public void MySqlDecimal()
+ {
+ execSQL("DROP TABLE IF EXISTS Test");
+ execSQL("CREATE TABLE Test (id INT, dec1 DECIMAL(36,2))");
+ execSQL("INSERT INTO Test VALUES (1, 9999999999999999999999999999999999.99)");
+
+ MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn);
+ using (MySqlDataReader reader = cmd.ExecuteReader())
+ {
+ reader.Read();
+ MySqlDecimal dec = reader.GetMySqlDecimal(1);
+ string s = dec.ToString();
+ Assert.AreEqual(9999999999999999999999999999999999.99, dec.ToDouble());
+ Assert.AreEqual("9999999999999999999999999999999999.99", dec.ToString());
+ try
+ {
+ decimal d = dec.Value;
+ Assert.Fail("this should have failed");
+ }
+ catch (Exception ex)
+ {
+ }
+ }
+ }
}
}
Attachment: [text/bzr-bundle] bzr/reggie.burnett@sun.com-20091029212954-i92x11pe0m571eu2.bundle
| Thread |
|---|
| • bzr push into connector-net-6.0 branch (reggie.burnett:771 to 772)Bug#48100 | Reggie Burnett | 29 Oct |