Skip to content

Commit

Permalink
Added Bypass Custom Plugins option
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMpn committed May 28, 2021
1 parent 3a78b73 commit bf144fa
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 42 deletions.
2 changes: 2 additions & 0 deletions MarkMpn.Sql4Cds.Engine.Tests/ExecutionPlanTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class ExecutionPlanTests : IQueryExecutionOptions

List<JoinOperator> IQueryExecutionOptions.JoinOperatorsAvailable => _supportedJoins;

bool IQueryExecutionOptions.BypassCustomPlugins => false;

bool IQueryExecutionOptions.ConfirmDelete(int count, EntityMetadata meta)
{
return true;
Expand Down
2 changes: 2 additions & 0 deletions MarkMpn.Sql4Cds.Engine.Tests/Sql2FetchXmlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class Sql2FetchXmlTests : IQueryExecutionOptions

List<JoinOperator> IQueryExecutionOptions.JoinOperatorsAvailable => new List<JoinOperator> { JoinOperator.Inner, JoinOperator.LeftOuter };

bool IQueryExecutionOptions.BypassCustomPlugins => false;

void IQueryExecutionOptions.RetrievingNextPage()
{
}
Expand Down
2 changes: 2 additions & 0 deletions MarkMpn.Sql4Cds.Engine.Tests/StubOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class StubOptions : IQueryExecutionOptions

List<JoinOperator> IQueryExecutionOptions.JoinOperatorsAvailable => new List<JoinOperator> { JoinOperator.Inner, JoinOperator.LeftOuter };

bool IQueryExecutionOptions.BypassCustomPlugins => false;

bool IQueryExecutionOptions.ConfirmDelete(int count, EntityMetadata meta)
{
return true;
Expand Down
3 changes: 3 additions & 0 deletions MarkMpn.Sql4Cds.Engine/ExecutionPlan/BaseDmlNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ protected string ExecuteDmlOperation(IOrganizationService org, IQueryExecutionOp

var request = requestGenerator(entity);

if (options.BypassCustomPlugins)
request.Parameters["BypassCustomPluginExecution"] = true;

if (options.BatchSize == 1)
{
var newCount = Interlocked.Increment(ref inProgressCount);
Expand Down
5 changes: 5 additions & 0 deletions MarkMpn.Sql4Cds.Engine/IQueryExecutionOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ public interface IQueryExecutionOptions
/// </summary>
List<JoinOperator> JoinOperatorsAvailable { get; }

/// <summary>
/// Indicates if plugins should be bypassed when executing DML operations
/// </summary>
bool BypassCustomPlugins { get; }

/// <summary>
/// A notification that the query is about to retrieve another page of data
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions MarkMpn.Sql4Cds.Engine/Sql2FetchXml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public QueryExecutionOptions(Sql2FetchXml sql2FetchXml)

public List<JoinOperator> JoinOperatorsAvailable => new List<JoinOperator> { JoinOperator.Inner, JoinOperator.LeftOuter };

public bool BypassCustomPlugins => false;

public bool ConfirmDelete(int count, EntityMetadata meta)
{
throw new NotImplementedException();
Expand Down
6 changes: 6 additions & 0 deletions MarkMpn.Sql4Cds.SSMS/OptionsPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public class OptionsPage : DialogPage
[DefaultValue(10)]
public int MaxDegreeOfParallelism { get; set; } = 10;

[Category("Behavior")]
[DisplayName("Bypass Custom Plugins")]
[Description("Skips executing custom plugins in response to INSERT/UPDATE/DELETE operations")]
[DefaultValue(false)]
public bool BypassCustomPlugins { get; set; }

[Category("Version")]
[DisplayName("Installed")]
[Description("Installed version of SQL 4 CDS - SSMS Edition")]
Expand Down
2 changes: 2 additions & 0 deletions MarkMpn.Sql4Cds.SSMS/QueryExecutionOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public QueryExecutionOptions(SqlScriptEditorControlWrapper sqlScriptEditorContro

public List<JoinOperator> JoinOperatorsAvailable => new List<JoinOperator>();

public bool BypassCustomPlugins => _options.BypassCustomPlugins;

public bool ConfirmDelete(int count, EntityMetadata meta)
{
if (count == 1)
Expand Down
2 changes: 2 additions & 0 deletions MarkMpn.Sql4Cds/QueryExecutionOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ public int LocaleId

public List<JoinOperator> JoinOperatorsAvailable => _joinOperators;

public bool BypassCustomPlugins => Settings.Instance.BypassCustomPlugins;

public void RetrievingNextPage()
{
_retrievedPages++;
Expand Down
2 changes: 2 additions & 0 deletions MarkMpn.Sql4Cds/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@ public class Settings
public bool AutoSizeColumns { get; set; } = true;

public int MaxRetrievesPerQuery { get; set; } = 100;

public bool BypassCustomPlugins { get; set; }
}
}
97 changes: 55 additions & 42 deletions MarkMpn.Sql4Cds/SettingsForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions MarkMpn.Sql4Cds/SettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public SettingsForm(Settings settings)
blockDeleteWithoutWhereCheckbox.Checked = settings.BlockDeleteWithoutWhere;
batchSizeUpDown.Value = settings.BatchSize;
bulkDeleteCheckbox.Checked = settings.UseBulkDelete;
bypassCustomPluginsCheckBox.Checked = settings.BypassCustomPlugins;
localTimesComboBox.SelectedIndex = settings.ShowLocalTimes ? 1 : 0;
tsqlEndpointCheckBox.Checked = settings.UseTSQLEndpoint;
retrieveTotalRecordCountCheckbox.Checked = settings.UseRetrieveTotalRecordCount;
Expand All @@ -52,6 +53,7 @@ protected override void OnClosing(CancelEventArgs e)
_settings.BlockDeleteWithoutWhere = blockDeleteWithoutWhereCheckbox.Checked;
_settings.BatchSize = (int) batchSizeUpDown.Value;
_settings.UseBulkDelete = bulkDeleteCheckbox.Checked;
_settings.BypassCustomPlugins = bypassCustomPluginsCheckBox.Checked;
_settings.ShowLocalTimes = localTimesComboBox.SelectedIndex == 1;
_settings.UseTSQLEndpoint = tsqlEndpointCheckBox.Checked;
_settings.UseRetrieveTotalRecordCount = retrieveTotalRecordCountCheckbox.Checked;
Expand Down

0 comments on commit bf144fa

Please sign in to comment.