Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Connector/NET commit: r999 - in branches/5.1/VisualStudio: . Descriptors

From: <rburnett(at)mysql.com>
Date: Fri Aug 31 2007 - 18:08:46 EDT


Modified:

   branches/5.1/VisualStudio/Descriptors/CollationDescriptor.cs
   branches/5.1/VisualStudio/Descriptors/ColumnDescriptor.cs
   branches/5.1/VisualStudio/Descriptors/EngineDescriptor.cs
   branches/5.1/VisualStudio/Descriptors/RootDescriptor.cs
   branches/5.1/VisualStudio/MySqlConnectionSupport.cs
   branches/5.1/VisualStudio/MySqlDataSourceInformation.cs
Log:
fixed several problems with VS integration and working with MySQL 4.1. The biggest problem was when you created a connection to a 5.0 server, stopped the server, deleted the connection, started a 4.1 server, and then remade the connection. The package would still attempt to use cached metadata for the 5.0 server.

Also added some workarounds for the infamous binary metadata issue of MySQL

Modified: branches/5.1/VisualStudio/Descriptors/CollationDescriptor.cs


  • branches/5.1/VisualStudio/Descriptors/CollationDescriptor.cs 2007-08-30 22:24:37 UTC (rev 998) +++ branches/5.1/VisualStudio/Descriptors/CollationDescriptor.cs 2007-08-31 22:08:45 UTC (rev 999)
    @@ -142,8 +142,11 @@
    throw new ArgumentNullException("connection");
             // Use base method to read table
-            DataTable result = base.ReadTable(connection, restrictions, sort);
+            DataTable first_result = base.ReadTable(connection, restrictions, sort);
 
+			// fixup collation names
+			DataTable result = MySqlConnectionSupport.ConvertAllBinaryColumns(first_result);
+
             // If there is now result from bas, return immediately
             if (result == null)
                 return result;

Modified: branches/5.1/VisualStudio/Descriptors/ColumnDescriptor.cs


  • branches/5.1/VisualStudio/Descriptors/ColumnDescriptor.cs 2007-08-30 22:24:37 UTC (rev 998) +++ branches/5.1/VisualStudio/Descriptors/ColumnDescriptor.cs 2007-08-31 22:08:45 UTC (rev 999)
    @@ -110,7 +110,7 @@
    [Field(OptionName = OrdinalOption, FieldType = TypeCode.Int64)] public const string Ordinal = "ORDINAL_POSITION"; [Field(FieldType = TypeCode.String)] - public const string Default = "TRUE_DEFAULT"; + public const string Default = "COLUMN_DEFAULT"; [Field(FieldType = TypeCode.Boolean)] public const string Nullable = "IS_NULLABLE"; [Field(OptionName = DataTypeOption, FieldType = TypeCode.String)]

Modified: branches/5.1/VisualStudio/Descriptors/EngineDescriptor.cs


  • branches/5.1/VisualStudio/Descriptors/EngineDescriptor.cs 2007-08-30 22:24:37 UTC (rev 998) +++ branches/5.1/VisualStudio/Descriptors/EngineDescriptor.cs 2007-08-31 22:08:45 UTC (rev 999)
    @@ -90,22 +90,7 @@
    { DataTable dt = base.ReadTable(connection, restrictions, sort);
    • // stupid hack to work around the issue that show engines returns
    • // everything as byte[]
    • DataTable newDT = dt.Clone();
    • foreach (DataColumn column in newDT.Columns)
    • column.DataType = typeof(System.String); -
    • Encoding e = Encoding.GetEncoding("latin1");
    • foreach (DataRow row in dt.Rows)
    • {
    • DataRow newRow = newDT.NewRow();
    • newRow[0] = e.GetString((byte[])row[0]);
    • newRow[1] = e.GetString((byte[])row[1]);
    • newRow[2] = e.GetString((byte[])row[2]);
    • newDT.Rows.Add(newRow);
    • }
    • return newDT; + return MySqlConnectionSupport.ConvertAllBinaryColumns(dt); } } }

Modified: branches/5.1/VisualStudio/Descriptors/RootDescriptor.cs


  • branches/5.1/VisualStudio/Descriptors/RootDescriptor.cs 2007-08-30 22:24:37 UTC (rev 998) +++ branches/5.1/VisualStudio/Descriptors/RootDescriptor.cs 2007-08-31 22:08:45 UTC (rev 999)
    @@ -109,7 +109,7 @@
    return base.GetDefaultRestrictions(connection);
             // For legacy version return array with current conection information
-            return new string[] { connection.ServerName, "'" + connection.Schema + "'" };
+            return new string[] { "'" + connection.ServerName + "'", "'" + connection.Schema + "'" };
         }
 
         /// 

Modified: branches/5.1/VisualStudio/MySqlConnectionSupport.cs


  • branches/5.1/VisualStudio/MySqlConnectionSupport.cs 2007-08-30 22:24:37 UTC (rev 998) +++ branches/5.1/VisualStudio/MySqlConnectionSupport.cs 2007-08-31 22:08:45 UTC (rev 999)
    @@ -27,6 +27,7 @@
    using Microsoft.VisualStudio.Data.AdoDotNet; using System.Globalization; using MySql.Data.VisualStudio.Properties; +using System.Text;

 namespace MySql.Data.VisualStudio
@@ -42,7 +43,9 @@

         /// Simple constructor
         /// 
         public MySqlConnectionSupport()
-            : base(MySqlConnectionProperties.Names.InvariantProviderName) { } 
+            : base(MySqlConnectionProperties.Names.InvariantProviderName) 
+		{
+		} 
         #endregion
 
         #region Overridden methods

@@ -66,6 +69,7 @@
// connection is OK, just close it normaly providerObjectVal.Close(); } + base.Close(); } ///
@@ -128,6 +132,8 @@
} // Rreturn true if everything is ok + if (sourceInformation != null) + sourceInformation.Refresh(); return true;
Do you need more help?X
}
@@ -152,7 +158,7 @@
} return viewSupport; } - if (serviceType == typeof(DataObjectSupport)) + else if (serviceType == typeof(DataObjectSupport)) { if (objectSupport == null) {
@@ -160,7 +166,7 @@
} return objectSupport; } - if (serviceType == typeof(DataSourceInformation)) + else if (serviceType == typeof(DataSourceInformation)) { if (sourceInformation == null) {
@@ -168,8 +174,7 @@
} return sourceInformation; } - object result = base.GetServiceImpl(serviceType); - return result; + else return base.GetServiceImpl(serviceType); } ///
@@ -296,7 +301,33 @@
#region Support entities private DataViewSupport viewSupport; private DataObjectSupport objectSupport; - private DataSourceInformation sourceInformation; + private MySqlDataSourceInformation sourceInformation; #endregion + + internal static DataTable ConvertAllBinaryColumns(DataTable dt) + { + // stupid hack to work around the issue that show engines returns + // everything as byte[] + DataTable newDT = dt.Clone(); + + foreach (DataColumn column in newDT.Columns) + if (column.DataType == typeof(System.Byte[])) + column.DataType = typeof(System.String); + + Encoding e = Encoding.GetEncoding("latin1"); + foreach (DataRow row in dt.Rows) + { + DataRow newRow = newDT.NewRow(); + foreach (DataColumn column in dt.Columns) + { + if (column.DataType == typeof(System.Byte[])) + newRow[column.Ordinal] = e.GetString((byte[])row[column.Ordinal]);
Can we help you?X
+ else + newRow[column.Ordinal] = row[column.Ordinal]; + } + newDT.Rows.Add(newRow); + } + return newDT; + } }

 }
Do you need help?X

Modified: branches/5.1/VisualStudio/MySqlDataSourceInformation.cs


  • branches/5.1/VisualStudio/MySqlDataSourceInformation.cs 2007-08-30 22:24:37 UTC (rev 998) +++ branches/5.1/VisualStudio/MySqlDataSourceInformation.cs 2007-08-31 22:08:45 UTC (rev 999)
    @@ -21,6 +21,8 @@
    using System; using Microsoft.VisualStudio.Data; using Microsoft.VisualStudio.Data.AdoDotNet; +using System.Data; +using System.Data.Common;

 namespace MySql.Data.VisualStudio
 {
@@ -30,7 +32,8 @@

 	public class MySqlDataSourceInformation : AdoDotNetDataSourceInformation
 	{
         #region Properties names
-        public const string DataSource = "DataSource";        
+        public const string DataSource = "DataSource";
+		private DataTable values;
         #endregion
 
         #region Constructor

@@ -42,6 +45,7 @@
: base(connection) { AddProperty(DataSource); + AddProperty(DataSourceVersion); AddProperty(DefaultSchema); AddProperty(SupportsAnsi92Sql, true); AddProperty(SupportsQuotedIdentifierParts, true);
@@ -59,7 +63,32 @@
} #endregion + internal void Refresh() + { + DbConnection c = (DbConnection)Connection.GetLockedProviderObject(); + values = c.GetSchema("DataSourceInformation"); + Connection.UnlockProviderObject(); + } + #region Value retrieving + + public override object this[string propertyName] + { + get + { + // data source version can change so we need to + // refresh it here + if (propertyName == "DataSourceVersion") + { + if (values == null) + Refresh(); + return values.Rows[0]["DataSourceProductVersion"]; + } + else + return base[propertyName]; + } + } + /// /// Called to retrieve property value. Supports following custom properties: /// DataSource – MySQL server name.
@@ -77,7 +106,8 @@
{ return ConnectionWrapper.Schema; } - return base.RetrieveValue(propertyName); + object value = base.RetrieveValue(propertyName); + return value; } #endregion
-- 
MySQL Code Commits Mailing List
Can't find what you're looking for?X
For list archives: http://lists.mysql.com/commits To unsubscribe: http://lists.mysql.com/commits?unsub=lists@pantek.com
Received on Fri Aug 31 18:10:12 2007

This archive was generated by hypermail 2.1.8 : Sun Oct 07 2007 - 09:02:12 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library