Skip to content

Commit

Permalink
added StatementTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen committed Sep 5, 2023
1 parent db71b18 commit 10b4c50
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 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.1] - 2023-09-05

### Added

- Added StatementTimeout to `Connect-Instance` command.

## [1.2.0] - 2023-08-24

### Changed
Expand Down
17 changes: 15 additions & 2 deletions src/PsSmo/ConnectInstanceCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public class ConnectInstanceCommand : PSCmdlet
[ValidateNotNullOrEmpty()]
public SecureString Password { get; set; }

[Parameter()]
public int StatementTimeout { get; set; } = 600;
#endregion

protected override void ProcessRecord()
Expand All @@ -111,6 +113,9 @@ protected override void ProcessRecord()
serverConnection: new ServerConnection(
sqlConnection: Connection
)
{
StatementTimeout = StatementTimeout
}
);
break;

Expand All @@ -124,6 +129,9 @@ protected override void ProcessRecord()
serverConnection: new ServerConnection(
sqlConnection: Connection
)
{
StatementTimeout = StatementTimeout
}
);
break;
}
Expand All @@ -138,8 +146,7 @@ protected override void ProcessRecord()
if (DataSource.EndsWith("database.windows.net"))
{
Connection = new SqlConnection(connectionString: builder.ConnectionString);
if (AccessToken == null)
AccessToken = new AzureServiceTokenProvider().GetAccessTokenAsync("https://database.windows.net").Result;
AccessToken ??= new AzureServiceTokenProvider().GetAccessTokenAsync("https://database.windows.net").Result;
Connection.AccessToken = AccessToken;
}
else
Expand All @@ -151,6 +158,9 @@ protected override void ProcessRecord()
serverConnection: new ServerConnection(
sqlConnection: Connection
)
{
StatementTimeout = StatementTimeout
}
);
break;
}
Expand All @@ -171,6 +181,9 @@ protected override void ProcessRecord()
serverConnection: new ServerConnection(
sqlConnection: Connection
)
{
StatementTimeout = StatementTimeout
}
);
break;
}
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.2.0'
ModuleVersion = '1.2.1'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down

0 comments on commit 10b4c50

Please sign in to comment.