Skip to content

Commit

Permalink
Merge branch 'release/1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen committed Aug 24, 2023
2 parents 729d1ed + 872c6e5 commit db71b18
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.2.0] - 2023-08-24

### Changed

- Verbose script execution prints the filepath.

## [1.1.0] - 2022-08-18

### Added
Expand Down
20 changes: 11 additions & 9 deletions src/PsSmo/InvokeCommandCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected override void ProcessRecord()
break;

case "File":
WriteVerbose("Execute SQL script from file.");
WriteVerbose($"Execute SQL script from file '{ InputFile.FullName }'.");
Text = File.ReadAllText(InputFile.FullName);
break;

Expand All @@ -54,14 +54,19 @@ protected override void ProcessRecord()
}
try
{
Instance.ConnectionContext.ExecuteNonQuery(sqlCommand: processSqlCmdText(Text, processVariables(Variables)));
} catch (Exception ex)
Instance.ConnectionContext.ExecuteNonQuery(sqlCommand: ProcessSqlCmdText(Text, ProcessVariables(Variables)));
}
catch (PipelineStoppedException)
{
throw;
}
catch (Exception ex)
{
WriteError(new ErrorRecord(ex, ex.GetType().Name, ErrorCategory.NotSpecified, Text));
}
}

private Dictionary<string, string> processVariables(Hashtable variables)
private static Dictionary<string, string> ProcessVariables(Hashtable variables)
{
var variableDictionary = new Dictionary<string, string>();

Expand All @@ -76,12 +81,9 @@ private Dictionary<string, string> processVariables(Hashtable variables)
return variableDictionary;
}

private string processSqlCmdText(string text, Dictionary<string, string> variables)
private string ProcessSqlCmdText(string text, Dictionary<string, string> variables)
{
if (variables == null)
{
variables = new Dictionary<string, string>();
}
variables ??= new Dictionary<string, string>();

var result = new List<string>();
var variableRegex = new Regex(@"\$\((\w*)\)");
Expand Down
2 changes: 1 addition & 1 deletion src/PsSmo/PsSmo.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PsSmo.dll'

# Version number of this module.
ModuleVersion = '1.1.0'
ModuleVersion = '1.2.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down

0 comments on commit db71b18

Please sign in to comment.