[Monodevelop-patches-list] r2744 - in trunk/MonoDevelop/Extras/MonoQuery: . Mono.Data.Sql Mono.Data.Sql/Providers MonoQuery MonoQuery/Gui MonoQuery/Gui/NodeBuilders

Christian Hergert <chris@mosaix.net> chergert at mono-cvs.ximian.com
Sun Aug 14 02:41:21 EDT 2005


Author: chergert
Date: 2005-08-14 02:41:21 -0400 (Sun, 14 Aug 2005)
New Revision: 2744

Modified:
   trunk/MonoDevelop/Extras/MonoQuery/ChangeLog
   trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/AssemblyInfo.cs
   trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/MySqlDbProvider.cs
   trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/NpgsqlDbProvider.cs
   trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/AssemblyInfo.cs
   trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/Gui/ConnectionDialog.cs
   trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/Gui/NodeBuilders/TableNodeBuilder.cs
Log:
* Mono.Data.Sql/AssemblyInfo.cs: Fix versioning stuff
* Mono.Data.Sql/Providers/NpgsqlDbProvider.cs: Update supported types.
properly close data readers.
* Mono.Data.Sql/Providers/MySqlDbProvider.cs: Add basic support for
tables, their columns, and users. This should be somewhat useful now. Need
to still determine which versions of mysql ByteFX driver works with.
* MonoQuery/AssemblyInfo.cs: Fix versioning stuff
* MonoQuery/Gui/NodeBuilders/TableNodeBuilder.cs: Update to check that the
type is supported before showing a dummy node.
* MonoQuery/Gui/ConnectionDialog.cs: Change Secret to Password.


Modified: trunk/MonoDevelop/Extras/MonoQuery/ChangeLog
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/ChangeLog	2005-08-14 06:08:13 UTC (rev 2743)
+++ trunk/MonoDevelop/Extras/MonoQuery/ChangeLog	2005-08-14 06:41:21 UTC (rev 2744)
@@ -1,5 +1,18 @@
 2005-08-06	Christian Hergert	<christian.hergert at gmail.com>
 
+	* Mono.Data.Sql/AssemblyInfo.cs: Fix versioning stuff
+	* Mono.Data.Sql/Providers/NpgsqlDbProvider.cs: Update supported types.
+	properly close data readers. 
+	* Mono.Data.Sql/Providers/MySqlDbProvider.cs: Add basic support for
+	tables, their columns, and users. This should be somewhat useful now. Need
+	to still determine which versions of mysql ByteFX driver works with.
+	* MonoQuery/AssemblyInfo.cs: Fix versioning stuff
+	* MonoQuery/Gui/NodeBuilders/TableNodeBuilder.cs: Update to check that the
+	type is supported before showing a dummy node.
+	* MonoQuery/Gui/ConnectionDialog.cs: Change Secret to Password.
+
+2005-08-06	Christian Hergert	<christian.hergert at gmail.com>
+
 	* Mono.Data.Sql.mds: Updated
 	* Mono.Data.Sql/Schema/ForeignKeyConstraintSchema.cs: Add setter for
 	reference table name.

Modified: trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/AssemblyInfo.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/AssemblyInfo.cs	2005-08-14 06:08:13 UTC (rev 2743)
+++ trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/AssemblyInfo.cs	2005-08-14 06:41:21 UTC (rev 2744)
@@ -26,7 +26,7 @@
 // You can specify all the values or you can default the Revision and Build Numbers 
 // by using the '*' as shown below:
 
-[assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
 
 //
 // In order to sign your assembly you must specify a key to use. Refer to the 

Modified: trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/MySqlDbProvider.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/MySqlDbProvider.cs	2005-08-14 06:08:13 UTC (rev 2743)
+++ trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/MySqlDbProvider.cs	2005-08-14 06:41:21 UTC (rev 2744)
@@ -43,7 +43,7 @@
 		
 		public override string ProviderName {
 			get {
-				return "MySQL Database (Incomplete)";
+				return "MySQL Database";
 			}
 		}
 		
@@ -89,6 +89,7 @@
 			} catch (Exception e) {
 				isConnectionStringWrong = true;
 			}
+
 			
 			return IsOpen;
 		}
@@ -101,33 +102,12 @@
 		
 		public override bool SupportsSchemaType(Type type)
 		{
-			// FIXME: Need to check what mysql actually supports.
 			if (type == typeof(TableSchema))
 				return true;
-			else if (type == typeof(ViewSchema))
+			if (type == typeof(ColumnSchema))
 				return true;
-			else if (type == typeof(ProcedureSchema))
-				return true;
-			else if (type == typeof(AggregateSchema))
-				return true;
-			else if (type == typeof(GroupSchema))
-				return true;
 			else if (type == typeof(UserSchema))
 				return true;
-			else if (type == typeof(LanguageSchema))
-				return true;
-			else if (type == typeof(OperatorSchema))
-				return true;
-			else if (type == typeof(RoleSchema))
-				return true;
-			else if (type == typeof(SequenceSchema))
-				return true;
-			else if (type == typeof(DataTypeSchema))
-				return true;
-			else if (type == typeof(TriggerSchema))
-				return true;
-			else if (type == typeof(RuleSchema))
-				return true;
 			else
 				return false;
 		}
@@ -155,49 +135,27 @@
 			
 			ArrayList collection = new ArrayList ();
 			
-			MySqlCommand command = new MySqlCommand ();
-			command.Connection = Connection;
-			command.CommandText =
-				"";
-			MySqlDataReader r = command.ExecuteReader ();
-			
-			while (r.Read ()) {
-				TableSchema table = new TableSchema ();
-				table.Provider = this;
+			using (MySqlCommand command = new MySqlCommand ()) {
+				command.Connection = Connection;
+				command.CommandText =
+					"SHOW TABLES;";
+				MySqlDataReader r = command.ExecuteReader ();
 				
-				// TODO: Implement
+				while (r.Read ()) {
+					TableSchema table = new TableSchema ();
+					table.Provider = this;
+					
+					table.Name = r.GetString (0);
+					
+					collection.Add (table);
+				}
 				
-				collection.Add (table);
+				r.Close ();
 			}
 			
 			return (TableSchema[]) collection.ToArray (typeof (TableSchema));
 		}
 		
-		public override ViewSchema[] GetViews ()
-		{
-			if (IsOpen == false && Open () == false)
-				throw new InvalidOperationException ("Invalid connection");
-			
-			ArrayList collection = new ArrayList ();
-			
-			MySqlCommand command = new MySqlCommand ();
-			command.Connection = Connection;
-			command.CommandText =
-				"";
-			MySqlDataReader r = command.ExecuteReader ();
-			
-			while (r.Read ()) {
-				ViewSchema view = new ViewSchema ();
-				view.Provider = this;
-				
-				// TODO: Implement
-				
-				collection.Add (view);
-			}
-			
-			return (ViewSchema[]) collection.ToArray (typeof (ViewSchema));
-		}
-		
 		public override ColumnSchema[] GetTableColumns (TableSchema table)
 		{
 			if (IsOpen == false && Open () == false)
@@ -205,73 +163,87 @@
 			
 			ArrayList collection = new ArrayList ();
 			
-			MySqlCommand command = new MySqlCommand ();
-			command.Connection = Connection;
-			command.CommandText =
-				"";
-			MySqlDataReader r = command.ExecuteReader ();
-			
-			while (r.Read ()) {
-				ColumnSchema column = new ColumnSchema ();
-				column.Provider = this;
+			using (MySqlCommand command = new MySqlCommand ()) {
+				command.Connection = Connection;
+
+				// XXX: Use String.Format cause mysql parameters suck assmar.
+				command.CommandText =
+					String.Format ("DESCRIBE {0}", table.Name);
+				MySqlDataReader r = command.ExecuteReader ();
 				
-				// TODO: Implement
+				while (r.Read ()) {
+					ColumnSchema column = new ColumnSchema ();
+					column.Provider = this;
+					
+					column.Name = r.GetString (0);
+					column.DataTypeName = r.GetString (1);
+					column.NotNull = r.IsDBNull (2);
+					column.Default = r.GetString (4);
+					column.Options["extra"] = r.GetString (5);
+					
+					collection.Add (column);
+				}
 				
-				collection.Add (column);
+				r.Close ();
 			}
 			
 			return (ColumnSchema[]) collection.ToArray (typeof (ColumnSchema));
 		}
 		
-		public override ColumnSchema[] GetViewColumns (ViewSchema table)
+		public override ConstraintSchema[] GetTableConstraints (TableSchema table)
 		{
 			if (IsOpen == false && Open () == false)
 				throw new InvalidOperationException ("Invalid connection");
 			
 			ArrayList collection = new ArrayList ();
 			
-			MySqlCommand command = new MySqlCommand ();
-			command.Connection = Connection;
-			command.CommandText =
-				"";
-			MySqlDataReader r = command.ExecuteReader ();
-			
-			while (r.Read ()) {
-				ColumnSchema column = new ColumnSchema ();
-				column.Provider = this;
+			using (MySqlCommand command = new MySqlCommand ()) {
+				command.Connection = Connection;
+				command.CommandText =
+					"";
+				MySqlDataReader r = command.ExecuteReader ();
 				
-				// TODO: Implement
+				while (r.Read ()) {
+					ConstraintSchema constraint = new ConstraintSchema ();
+					constraint.Provider = this;
+					
+					// TODO: Implement
+					
+					collection.Add (constraint);
+				}
 				
-				collection.Add (column);
+				r.Close ();
 			}
 			
-			return (ColumnSchema[]) collection.ToArray (typeof (ColumnSchema));
+			return (ConstraintSchema[]) collection.ToArray (
+				typeof (ConstraintSchema));
 		}
-		
-		public override ConstraintSchema[] GetTableConstraints (TableSchema table)
+
+		public override UserSchema[] GetUsers ()
 		{
 			if (IsOpen == false && Open () == false)
 				throw new InvalidOperationException ("Invalid connection");
-			
+
 			ArrayList collection = new ArrayList ();
-			
-			MySqlCommand command = new MySqlCommand ();
-			command.Connection = Connection;
-			command.CommandText =
-				"";
-			MySqlDataReader r = command.ExecuteReader ();
-			
-			while (r.Read ()) {
-				ConstraintSchema constraint = new ConstraintSchema ();
-				constraint.Provider = this;
-				
-				// TODO: Implement
-				
-				collection.Add (constraint);
+
+			using (MySqlCommand command = new MySqlCommand ()) {
+				command.Connection = connection;
+				command.CommandText =
+					"SELECT DISTINCT user from mysql.user where user != '';";
+				MySqlDataReader r = command.ExecuteReader ();
+
+				while (r.Read ()) {
+					UserSchema user = new UserSchema ();
+					user.Provider = this;
+					user.Name = r.GetString (0);
+
+					collection.Add (user);
+				}
+
+				r.Close ();
 			}
-			
-			return (ConstraintSchema[]) collection.ToArray (
-				typeof (ConstraintSchema));
+
+			return (UserSchema[]) collection.ToArray (typeof (UserSchema));
 		}
 	}
 }

Modified: trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/NpgsqlDbProvider.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/NpgsqlDbProvider.cs	2005-08-14 06:08:13 UTC (rev 2743)
+++ trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/NpgsqlDbProvider.cs	2005-08-14 06:41:21 UTC (rev 2744)
@@ -189,6 +189,10 @@
 				return true;
 			else if (type == typeof(TriggerSchema))
 				return true;
+			else if (type == typeof(ColumnSchema))
+				return true;
+			else if (type == typeof(ConstraintSchema))
+				return true;
 			else if (type == typeof(RuleSchema))
 				return true;
 			else
@@ -281,6 +285,8 @@
 				collection.Add (table);
 			}
 			
+			r.Close ();
+			
 			return (TableSchema[]) collection.ToArray (typeof (TableSchema));
 		}
 		
@@ -339,6 +345,8 @@
 				collection.Add(column);
 			}
 			
+			r.Close ();
+			
 			return (ColumnSchema[]) collection.ToArray(typeof(ColumnSchema));
 		}
 
@@ -383,12 +391,12 @@
 					view.Comment = r.GetString(5);
 				} catch (Exception e) {
 				}
-				
-				
-				
+
 				collection.Add(view);
 			}
 			
+			r.Close ();
+			
 			return (ViewSchema[]) collection.ToArray (typeof (ViewSchema));
 		}
 		
@@ -436,6 +444,8 @@
 				}
 			}
 			
+			r.Close ();
+			
 			return (ColumnSchema[]) collection.ToArray (typeof(ColumnSchema));
 		}
 		
@@ -508,6 +518,8 @@
 				collection.Add (constraint);
 			}
 			
+			r.Close ();
+			
 			return (ConstraintSchema[]) collection.ToArray (typeof(ConstraintSchema));
 		}
 		
@@ -555,6 +567,8 @@
 				collection.Add (user);
 			}
 			
+			r.Close ();
+			
 			return (UserSchema[]) collection.ToArray (typeof (UserSchema));
 		}
 		
@@ -605,6 +619,7 @@
 				collection.Add (procedure);
 			}
 			
+			r.Close ();
 			
 			return (ProcedureSchema[]) collection.ToArray (typeof (ProcedureSchema)); 
 		}
@@ -638,6 +653,8 @@
 				collection.Add (column);
 			}
 			
+			r.Close ();
+			
 			return (ColumnSchema[]) collection.ToArray (typeof (ColumnSchema));
 		}
 	}

Modified: trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/AssemblyInfo.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/AssemblyInfo.cs	2005-08-14 06:08:13 UTC (rev 2743)
+++ trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/AssemblyInfo.cs	2005-08-14 06:41:21 UTC (rev 2744)
@@ -23,7 +23,7 @@
 // You can specify all values by your own or you can build default build and revision
 // numbers with the '*' character (the default):
 
-[assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
 
 // The following attributes specify the key for the sign of your assembly. See the
 // .NET Framework documentation for more information about signing.

Modified: trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/Gui/ConnectionDialog.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/Gui/ConnectionDialog.cs	2005-08-14 06:08:13 UTC (rev 2743)
+++ trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/Gui/ConnectionDialog.cs	2005-08-14 06:41:21 UTC (rev 2744)
@@ -125,11 +125,11 @@
 			if (useridEntry.Text != String.Empty)
 				connString += String.Format ("User ID={0};", useridEntry.Text);
 			if (passwordEntry.Text != String.Empty)
-				connString += String.Format ("Secret={0};", passwordEntry.Text);
+				connString += String.Format ("Password={0};", passwordEntry.Text);
 			if (otherEntry.Text != String.Empty)
 				connString += otherEntry.Text;
 			
 			connectionStringTextView.Buffer.Text = connString;
 		}
 	}
-}
\ No newline at end of file
+}

Modified: trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/Gui/NodeBuilders/TableNodeBuilder.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/Gui/NodeBuilders/TableNodeBuilder.cs	2005-08-14 06:08:13 UTC (rev 2743)
+++ trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/Gui/NodeBuilders/TableNodeBuilder.cs	2005-08-14 06:41:21 UTC (rev 2744)
@@ -77,10 +77,17 @@
 		
 		public static void BuildChildNodes (ITreeBuilder builder, TableSchema node)
 		{
-			builder.AddChild (new ColumnsNode (node.Provider, node));
-			builder.AddChild (new RulesNode (node.Provider));
-			builder.AddChild (new ConstraintsNode (node.Provider, node));
-			builder.AddChild (new TriggersNode (node.Provider));
+			if (node.Provider.SupportsSchemaType (typeof (ColumnSchema)))
+				builder.AddChild (new ColumnsNode (node.Provider, node));
+
+			if (node.Provider.SupportsSchemaType (typeof (RuleSchema)))
+				builder.AddChild (new RulesNode (node.Provider));
+
+			if (node.Provider.SupportsSchemaType (typeof (ConstraintSchema)))
+				builder.AddChild (new ConstraintsNode (node.Provider, node));
+
+			if (node.Provider.SupportsSchemaType (typeof (TriggerSchema)))
+				builder.AddChild (new TriggersNode (node.Provider));
 		}
 		
 		public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
@@ -120,4 +127,4 @@
 			Runtime.Gui.Workbench.ShowView (dataView, true);
 		}
 	}
-}
\ No newline at end of file
+}




More information about the Monodevelop-patches-list mailing list