List:Commits« Previous MessageNext Message »
From:rburnett Date:May 7 2008 3:51pm
Subject:Connector/NET commit: r1283 - branches/5.2/MySql.Data/Provider/Source
View as plain text  
Modified:
   branches/5.2/MySql.Data/Provider/Source/CommandBuilder.cs
   branches/5.2/MySql.Data/Provider/Source/Statement.cs
   branches/5.2/MySql.Data/Provider/Source/StoredProcedure.cs
Log:
a few fixes related to using @ for a parameter marker with sprocs and also with parameters
that have @ as part of their name

Modified: branches/5.2/MySql.Data/Provider/Source/CommandBuilder.cs
===================================================================
--- branches/5.2/MySql.Data/Provider/Source/CommandBuilder.cs	2008-05-07 13:47:00 UTC (rev
1282)
+++ branches/5.2/MySql.Data/Provider/Source/CommandBuilder.cs	2008-05-07 13:51:36 UTC (rev
1283)
@@ -114,10 +114,9 @@
             foreach (DataRow row in parameters.Rows)
             {
                 MySqlParameter p = new MySqlParameter();
-                p.ParameterName = row["PARAMETER_NAME"].ToString();
-                p.Direction = GetDirection(row["PARAMETER_MODE"].ToString(),
-                    row["IS_RESULT"].ToString());
-                bool unsigned = row["FLAGS"].ToString().IndexOf("UNSIGNED") != -1;
+                p.ParameterName = String.Format("@{0}", row["PARAMETER_NAME"]);
+                p.Direction = GetDirection(row);
+                bool unsigned =
StoredProcedure.GetFlags(row["DTD_IDENTIFIER"].ToString()).IndexOf("UNSIGNED") != -1;
                 bool real_as_float =
procTable.Rows[0]["SQL_MODE"].ToString().IndexOf("REAL_AS_FLOAT") != -1;
                 p.MySqlDbType = MetaData.NameToType(row["DATA_TYPE"].ToString(),
                     unsigned, real_as_float, command.Connection);
@@ -131,13 +130,16 @@
             }
         }
 
-        private static ParameterDirection GetDirection(string direction, string
is_result)
+        private static ParameterDirection GetDirection(DataRow row)
         {
-            if (is_result == "YES")
+            string mode = row["PARAMETER_MODE"].ToString();
+            int ordinal = Convert.ToInt32(row["ORDINAL_POSITION"]);
+
+            if (0 == ordinal)
                 return ParameterDirection.ReturnValue;
-            else if (direction == "IN")
+            else if (mode == "IN")
                 return ParameterDirection.Input;
-            else if (direction == "OUT")
+            else if (mode == "OUT")
                 return ParameterDirection.Output;
             return ParameterDirection.InputOutput;
         }

Modified: branches/5.2/MySql.Data/Provider/Source/Statement.cs
===================================================================
--- branches/5.2/MySql.Data/Provider/Source/Statement.cs	2008-05-07 13:47:00 UTC (rev
1282)
+++ branches/5.2/MySql.Data/Provider/Source/Statement.cs	2008-05-07 13:51:36 UTC (rev
1283)
@@ -328,6 +328,7 @@
                 else if (c == '\\')
                     escaped = !escaped;
                 else if (sqlPart.Length == 1 && sqlPart[0] == '@' && c ==
'@') { }
+                else if (sqlPart.Length > 0 && sqlPart[0] == '?' && c
== '@') { }
                 else if ((c == '@' || c == '?') && delim == Char.MinValue
&& !escaped)
                 {
                     tokens.Add(sqlPart.ToString());

Modified: branches/5.2/MySql.Data/Provider/Source/StoredProcedure.cs
===================================================================
--- branches/5.2/MySql.Data/Provider/Source/StoredProcedure.cs	2008-05-07 13:47:00 UTC
(rev 1282)
+++ branches/5.2/MySql.Data/Provider/Source/StoredProcedure.cs	2008-05-07 13:51:36 UTC
(rev 1283)
@@ -118,6 +118,14 @@
             return ds;
         }
 
+        public static string GetFlags(string dtd)
+        {
+            int x = dtd.Length - 1;
+            while (x > 0 && (Char.IsLetterOrDigit(dtd[x]) || dtd[x] == ' '))
+                x--;
+            return dtd.Substring(x).ToUpperInvariant();
+        }
+
         public override void Resolve()
         {
             // first retrieve the procedure definition from our
@@ -142,13 +150,19 @@
                 string mode = (string) param["PARAMETER_MODE"];
                 string pName = (string) param["PARAMETER_NAME"];
 
+                // if the base parametr name starts with @ then our parameter must start
with ?
+                if (pName.StartsWith("@"))
+                    pName = "?" + pName;
+                else if (!pName.StartsWith("?"))
+                    pName = "@" + pName;
+
                 // make sure the parameters given to us have an appropriate
                 // type set if it's not already
                 MySqlParameter p = command.Parameters.GetParameterFlexible(pName, true);
                 if (!p.TypeHasBeenSet)
                 {
                     string datatype = (string) param["DATA_TYPE"];
-                    bool unsigned = param["FLAGS"].ToString().IndexOf("UNSIGNED") != -1;
+                    bool unsigned =
GetFlags(param["DTD_IDENTIFIER"].ToString()).IndexOf("UNSIGNED") != -1;
                     bool real_as_float =
procTable.Rows[0]["SQL_MODE"].ToString().IndexOf("REAL_AS_FLOAT") != -1;
                     p.MySqlDbType = MetaData.NameToType(datatype, unsigned,
real_as_float, Connection);
                 }

Thread
Connector/NET commit: r1283 - branches/5.2/MySql.Data/Provider/Sourcerburnett7 May