Modified:
branches/5.1/VisualStudio/Commands/DropCommand.cs
branches/5.1/VisualStudio/Descriptors/StoredProcDescriptor.cs
branches/5.1/VisualStudio/DocumentView/Documents/StoredProcDocument.cs
Log:
Some small fixes to the drop and clone operations for stored procs
Modified: branches/5.1/VisualStudio/Commands/DropCommand.cs
===================================================================
--- branches/5.1/VisualStudio/Commands/DropCommand.cs 2007-09-20 14:33:45 UTC (rev 1008)
+++ branches/5.1/VisualStudio/Commands/DropCommand.cs 2007-09-20 14:34:35 UTC (rev 1009)
@@ -122,8 +122,14 @@
}
// Build DROP query
- string dropQuery = descriptor.BuildDropSql(identifier);
- if (String.IsNullOrEmpty(dropQuery))
+ string dropQuery = String.Empty;
+ if (descriptor is StoredProcDescriptor)
+ dropQuery = (descriptor as StoredProcDescriptor).BuildDropSql(
+ hierarchy, item, identifier);
+ else
+ dropQuery = descriptor.BuildDropSql(identifier);
+
+ if (String.IsNullOrEmpty(dropQuery))
{
Debug.Fail("Failed to build DROP query!");
return null;
Modified: branches/5.1/VisualStudio/Descriptors/StoredProcDescriptor.cs
===================================================================
--- branches/5.1/VisualStudio/Descriptors/StoredProcDescriptor.cs 2007-09-20 14:33:45 UTC (rev 1008)
+++ branches/5.1/VisualStudio/Descriptors/StoredProcDescriptor.cs 2007-09-20 14:34:35 UTC (rev 1009)
@@ -165,27 +165,21 @@
/// </summary>
/// <param name="identifier">Database object identifier.</param>
/// <returns>Returns DROP TABLE statement.</returns>
- public override string BuildDropSql(object[] identifier)
+ public string BuildDropSql(ServerExplorerFacade hierarchy,
+ int item, object[] identifier)
{
if (identifier == null)
throw new ArgumentNullException("identifier");
- if (identifier.Length != 4 || String.IsNullOrEmpty(identifier[1] as string)
- || String.IsNullOrEmpty(identifier[2] as string) || String.IsNullOrEmpty(identifier[3] as string))
- throw new ArgumentException(
- String.Format(
- CultureInfo.CurrentCulture,
- Resources.Error_InvlaidIdentifier,
- identifier.Length,
- TypeName,
- 4),
- "identifier");
+ int parentId = hierarchy.GetParent(item);
+ string parentName = hierarchy.GetName(parentId);
+
// Build query
StringBuilder query = new StringBuilder("DROP ");
- query.Append(identifier[2]);
+ query.Append(parentName == "Stored Procedures" ? "PROCEDURE" : "FUNCTION");
query.Append(' ');
- QueryBuilder.WriteIdentifier(identifier[1] as string, identifier[3] as string, query);
+ QueryBuilder.WriteIdentifier(identifier[1] as string, identifier[2] as string, query);
return query.ToString();
}
#endregion
Modified: branches/5.1/VisualStudio/DocumentView/Documents/StoredProcDocument.cs
===================================================================
--- branches/5.1/VisualStudio/DocumentView/Documents/StoredProcDocument.cs 2007-09-20 14:33:45 UTC (rev 1008)
+++ branches/5.1/VisualStudio/DocumentView/Documents/StoredProcDocument.cs 2007-09-20 14:34:35 UTC (rev 1009)
@@ -445,7 +445,7 @@
newRow[StoredProc.Definition] = body;
}
- public override object[] ObjectIDForLoad
+/* public override object[] ObjectIDForLoad
{
get
{
@@ -458,7 +458,7 @@
return newId;
}
}
-
+ */
/// <summary>
/// Loads a routine from a database
/// </summary>
| Thread |
|---|
| • Connector/NET commit: r1009 - in branches/5.1/VisualStudio: Commands Descriptors DocumentView/Documents | rburnett | 20 Sep |