Skip to content

Commit

Permalink
Made delete table more backwards compatible for SQL Server
Browse files Browse the repository at this point in the history
  • Loading branch information
Joakim Wennergren committed Nov 30, 2017
1 parent a88c579 commit 22ec5d9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions CsvQuery/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static void OnNotification(ScNotification notification)
// This method is invoked whenever something is happening in notepad++. Use as:
// if (notification.Header.Code == (uint)NppMsg.NPPN_xxx) {...}
// (or SciMsg.SCNxxx)
Trace.TraceInformation($"Npp notification received: {notification.Header.EventType}");
//Trace.TraceInformation($"Npp notification received: {notification.Header.EventType}");
}

public static void CommandMenuInit()
Expand All @@ -108,7 +108,6 @@ public static void CommandMenuInit()
PluginBase.AddMenuItem("List parsed files", ListSqliteTables);
PluginBase.AddMenuItem("---", null);
PluginBase.AddMenuItem("&Settings", Settings.ShowDialog);
////PluginBase.AddMenuItem("Settings file", Settings.OpenFile);
PluginBase.AddMenuItem("&About", AboutCsvQuery);
}

Expand Down
3 changes: 2 additions & 1 deletion CsvQuery/Tools/DataStorageBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public void SetActiveTab(IntPtr bufferId)
_currentActiveBufferId = bufferId;
}
}

public abstract string SaveData(IntPtr bufferId, List<string[]> data, bool? hasHeader);
public List<string[]> ExecuteQuery(string query) => ExecuteQuery(query, false);
public List<string[]> ExecuteQueryWithColumnNames(string query) => ExecuteQuery(query, true);
Expand All @@ -38,13 +39,13 @@ protected string GetOrAllocateTableName(IntPtr bufferId)
if (_createdTables.ContainsKey(bufferId))
{
tableName = _createdTables[bufferId];
ExecuteNonQuery("DROP TABLE IF EXISTS " + tableName);
}
else
{
tableName = "T" + ++_lastCreatedTableName;
_createdTables.Add(bufferId, tableName);
}
ExecuteNonQuery("DROP TABLE IF EXISTS " + tableName);
return tableName;
}
}
Expand Down
3 changes: 1 addition & 2 deletions CsvQuery/Tools/MssqlDataStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,13 @@ public string SaveData(IntPtr bufferId, List<string[]> data, bool? hasHeader)
if (_createdTables.ContainsKey(bufferId))
{
tableName = _createdTables[bufferId];
ExecuteNonQuery("DROP TABLE IF EXISTS " + tableName);
}
else
{
tableName = "T" + ++_lastCreatedTableName;
ExecuteNonQuery("DROP TABLE IF EXISTS " + tableName);
_createdTables.Add(bufferId, tableName);
}
ExecuteNonQuery($"IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '{tableName}' AND TABLE_SCHEMA = 'dbo') DROP TABLE dbo.{tableName}");

var columnTypes = CsvAnalyzer.DetectColumnTypes(data, hasHeader);

Expand Down

0 comments on commit 22ec5d9

Please sign in to comment.