MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:rburnett Date:April 17 2009 4:21pm
Subject:Connector/NET commit: r1560 - in trunk: . MySql.Data/Provider/Source/common MySql.Data/Tests/Source
View as plain text  
Modified:
   trunk/CHANGES
   trunk/MySql.Data/Provider/Source/common/MySqlTokenizer.cs
   trunk/MySql.Data/Tests/Source/Tokenizer.cs
Log:
- fixed problem with new tokenizer that caused some values with equals to not be parsed correctly (bug #44318)


Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES	2009-04-14 21:25:11 UTC (rev 1559)
+++ trunk/CHANGES	2009-04-17 16:21:42 UTC (rev 1560)
@@ -8,6 +8,8 @@
 - fixed registration problem with Visual studio (bug #44064)
 - fixed problem where stored procedures and functions could not be deleted from server explorer
 - changed function generation so that it ignores schema just like we did with tables in 6.0.1
+- fixed problem with new tokenizer that caused some values with equals to not be parsed
+  correctly (bug #44318)
 
 Version 6.0.1
 - Fixed problem with the foreign key columns schema collection

Modified: trunk/MySql.Data/Provider/Source/common/MySqlTokenizer.cs
===================================================================
--- trunk/MySql.Data/Provider/Source/common/MySqlTokenizer.cs	2009-04-14 21:25:11 UTC (rev 1559)
+++ trunk/MySql.Data/Provider/Source/common/MySqlTokenizer.cs	2009-04-17 16:21:42 UTC (rev 1560)
@@ -128,6 +128,7 @@
             while (FindToken())
             {
                 if ((stopIndex - startIndex) < 2) continue;
+         string token = sql.Substring(startIndex, stopIndex - startIndex).Trim();
                 char c1 = sql[startIndex];
                 char c2 = sql[startIndex+1];
                 if (c1 != '@' && c1 != '?') continue;
@@ -271,7 +272,14 @@
 
         private bool IsSpecialCharacter(char c)
         {
-            return c == '(' || c == ')' || c == ',' || c == ';' || c == '-' || c == '/' || c == '#';
+            return c == '=' || 
+                   c == '(' || 
+                   c == ')' || 
+                   c == ',' || 
+                   c == ';' || 
+                   c == '-' || 
+                   c == '/' || 
+                   c == '#';
         }
     }
 }

Modified: trunk/MySql.Data/Tests/Source/Tokenizer.cs
===================================================================
--- trunk/MySql.Data/Tests/Source/Tokenizer.cs	2009-04-14 21:25:11 UTC (rev 1559)
+++ trunk/MySql.Data/Tests/Source/Tokenizer.cs	2009-04-17 16:21:42 UTC (rev 1560)
@@ -124,10 +124,12 @@
             Assert.AreEqual("FROM", tokenizer.NextToken());
             Assert.AreEqual("Test", tokenizer.NextToken());
             Assert.AreEqual("WHERE", tokenizer.NextToken());
-            Assert.AreEqual("id=", tokenizer.NextToken());
+            Assert.AreEqual("id", tokenizer.NextToken());
+            Assert.AreEqual("=", tokenizer.NextToken());
             Assert.AreEqual("@id", tokenizer.NextToken());
             Assert.AreEqual("AND", tokenizer.NextToken());
-            Assert.AreEqual("id2=", tokenizer.NextToken());
+            Assert.AreEqual("id2", tokenizer.NextToken());
+            Assert.AreEqual("=", tokenizer.NextToken());
             Assert.AreEqual("?id2", tokenizer.NextToken());
             Assert.IsNull(tokenizer.NextToken());
         }
@@ -154,7 +156,8 @@
             Assert.AreEqual("FROM", tokenizer.NextToken());
             Assert.AreEqual("Test", tokenizer.NextToken());
             Assert.AreEqual("WHERE", tokenizer.NextToken());
-            Assert.AreEqual("id=", tokenizer.NextToken());
+            Assert.AreEqual("id", tokenizer.NextToken());
+            Assert.AreEqual("=", tokenizer.NextToken());
             Assert.AreEqual("@id_$123", tokenizer.NextToken());
             Assert.IsNull(tokenizer.NextToken());
         }
@@ -234,5 +237,27 @@
             Assert.IsNull(tokenizer.NextToken());
         }
 #endif
+
+        /// <summary>
+        /// Bug #44318	Tokenizer
+        /// </summary>
+        [Test]
+        public void NoSpaceAroundEquals()
+        {
+            execSQL("DROP TABLE IF EXISTS Test");
+            execSQL("CREATE TABLE Test(name VARCHAR(40))");
+
+            MySqlCommand cmd = new MySqlCommand("INSERT INTO Test SET name='test -- test';", conn);
+            cmd.ExecuteNonQuery();
+            cmd.CommandText = "SELECT name FROM Test";
+            object o = cmd.ExecuteScalar();
+            Assert.AreEqual("test -- test", o);
+
+            cmd.CommandText = "UPDATE Test SET name='Can you explain this ?';";
+            cmd.ExecuteNonQuery();
+            cmd.CommandText = "SELECT name FROM Test";
+            o = cmd.ExecuteScalar();
+            Assert.AreEqual("Can you explain this ?", o);
+        }
     }
 }

Thread
Connector/NET commit: r1560 - in trunk: . MySql.Data/Provider/Source/common MySql.Data/Tests/Sourcerburnett17 Apr