List:Commits« Previous MessageNext Message »
From:Vladislav Vaintroub Date:November 4 2009 4:46pm
Subject:bzr commit into connector-net-trunk branch (vvaintroub:792)
View as plain text  
#At file:///H:/connector_net/trunk/ based on
revid:reggie.burnett@stripped

  792 Vladislav Vaintroub	2009-11-04 [merge]
      merge

    modified:
      CHANGES
      MySql.Data/Provider/Source/Types/MySqlDecimal.cs
      MySql.Data/Provider/Source/datareader.cs
      MySql.Data/Tests/Source/DataTypeTests.cs
      MySql.Web/Providers/Source/SessionProvider.cs
=== modified file 'CHANGES'
--- a/CHANGES	2009-10-28 16:09:25 +0000
+++ b/CHANGES	2009-11-04 15:45:47 +0000
@@ -1,9 +1,12 @@
 Version 6.2.1
+- fixed SessionProvider to be compatible with 4.x MySQL, replaced TIMESTAMPDIFF with
TIME_TO_SEC
+  (bug#47219)
 - implemented support for client SSL certificates
 - fixed indexes schema collection so that it still works with bad table names such as
b``a`d (bug #48101)
 - fixed guid type so that multi-byte character sets will not effect how it works.  A
column would be
   considered a guid if it has a *character* length of 36, not a *byte* length of 36 (bug
#47985)
 - 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.2.0
 - we now cleanup idle connections in the pool, if they were not used for too long

=== 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 @@ using System.Globalization;
 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 @@ namespace MySql.Data.Types
 
 		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 @@ namespace MySql.Data.Types
 			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-10-09 21:44:54 +0000
+++ b/MySql.Data/Provider/Source/datareader.cs	2009-10-29 21:36:59 +0000
@@ -415,6 +415,16 @@ namespace MySql.Data.MySqlClient
 				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-10-23 19:02:53 +0000
+++ b/MySql.Data/Tests/Source/DataTypeTests.cs	2009-10-29 21:36:59 +0000
@@ -1004,5 +1004,34 @@ namespace MySql.Data.MySqlClient.Tests
                 }
             }
         }
+
+        /// <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) 
+                {
+                }
+            }
+        }
     }
 }

=== modified file 'MySql.Web/Providers/Source/SessionProvider.cs'
--- a/MySql.Web/Providers/Source/SessionProvider.cs	2009-10-14 23:15:49 +0000
+++ b/MySql.Web/Providers/Source/SessionProvider.cs	2009-11-04 15:45:47 +0000
@@ -521,7 +521,7 @@ namespace MySql.Web.SessionState
                     // Retrieve the current session item information.
                     cmd = new MySqlCommand(
                       "SELECT (NOW() > Expires) as Expired, SessionItems, LockId, 
Flags, Timeout, " +
-                      "  TIMESTAMPDIFF(SECOND, LockDate, NOW()) as lockAge " +
+                      "  TIME_TO_SEC(NOW() - LockDate) as lockAge " +
                       "  FROM my_aspnet_Sessions" +
                       "  WHERE SessionId = @SessionId AND ApplicationId =
@ApplicationId", conn);
 


Attachment: [text/bzr-bundle] bzr/vvaintroub@mysql.com-20091104154650-ofn3poc45sblampk.bundle
Thread
bzr commit into connector-net-trunk branch (vvaintroub:792)Vladislav Vaintroub4 Nov 2009