-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from webmd-health-services/feature/metadata-fun…
…ctions 1.1.0 Metadata functions for Microsoft SQL Server
- Loading branch information
Showing
37 changed files
with
2,531 additions
and
522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!-- markdownlint-disable MD012 no-multiple-blanks --> | ||
|
||
# Yodel Changelog | ||
|
||
## 1.1.0 | ||
|
||
### Added | ||
|
||
Functions specific to Microsoft SQL Server: | ||
|
||
* `ConvertTo-YMsSqlIdentifier` for converting a string to an identifer, quoted with square brackets. | ||
* `Get-YMsSqlExtendedProperty` for getting extended properties. | ||
* `Get-YMsSqlSchema` for getting metadata about a schema. | ||
* `Get-YMsSqlTable` for getting metadata about a table. | ||
* `Get-YMsSqlTableColumn` for getting metadata about a table. | ||
* `Initialize-YMsSqlDatabase` for creating a database. | ||
* `Initialze-YMsSqlSchema` for creating a schema. | ||
* `Invoke-YMsSqlCommand` for running queries and commands. | ||
* `Remove-YMsSqlTable` for dropping a table. | ||
* `Set-YMsSqlExtendedProperty` for adding/updating extended properties. | ||
* `Test-YMsSqlExtendedProperty` for testing if an extended property exists. | ||
* `Test-YMsSqlSchema` for testing if a schema exists. | ||
* `Test-YMsSqlTable` for testing if a table exists. | ||
* `Test-YMsSqlTableColumn` for testing if a table column exists. | ||
|
||
### Deprecated | ||
|
||
* The `Invoke-YSqlServerCommand` function. Replaced with `Invoke-YMsSqlCommand`. | ||
|
||
|
||
## 1.0.0 | ||
|
||
> Released 18 Mar 2020 | ||
* Created Connect-YDatabase function for connecting to an ADO.NET data source, like a SQL Server database. | ||
* Created Invoke-YDbCommand function for executing an ADO.NET command, like a SQL query or stored procedure. | ||
* Created Invoke-YSqlServerCommand function for executing commands against a SQL Server database. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Yodel | ||
|
||
Copyright 2023 WebMD Health Services | ||
|
||
This product includes software developed at WebMD Health Services (https://www.webmdhealthservices.com/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
#Requires -Version 5.1 | ||
Set-StrictMode -Version 'Latest' | ||
|
||
BeforeAll { | ||
Set-StrictMode -Version 'Latest' | ||
|
||
& (Join-Path -Path $PSScriptRoot -ChildPath 'Initialize-YodelTest.ps1' -Resolve) | ||
|
||
$script:conn = Get-YTMSSqlConnection | ||
} | ||
|
||
Describe 'Get-ExtendedProperty' { | ||
BeforeEach { | ||
} | ||
|
||
AfterEach { | ||
} | ||
|
||
It 'gets extended property on schema' { | ||
$schemaName = 'get-ymssqlextendedproperty' | ||
$propName = 'Yodel_Get-ExtendedProperty_Test1' | ||
GivenMSSqlSchema $schemaName | ||
GivenMSSqlExtendedProperty $propName -WithValue 'from test 1' -OnSchema $schemaName | ||
ThenMSSqlExtendedProperty $propName -OnSchema $schemaName -HasValue 'from test 1' | ||
} | ||
|
||
It 'gets extended property on table' { | ||
$tableName = 'get-extendedproptable' | ||
$propName = 'Yodel_Get-ExtendedProperty_Test2' | ||
GivenMSSqlTable $tableName 'id int not null' | ||
GivenMSSqlExtendedProperty $propName -WithValue 'from test 2' -OnTable $tableName | ||
ThenMSSqlExtendedProperty $propName -OnTable $tableName -HasValue 'from test 2' | ||
} | ||
|
||
It 'gets extended property on table column' { | ||
$tableName = 'get-extendedproptable' | ||
$propName = 'Yodel_Get-ExtendedProperty_Test3' | ||
GivenMSSqlTable $tableName 'id int not null' | ||
GivenMSSqlExtendedProperty $propName -WithValue 'from test 3' -OnTable $tableName -OnColumn 'id' | ||
ThenMSSqlExtendedProperty $propName -OnTable $tableName -OnColumn 'id' -HasValue 'from test 3' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
|
||
#Requires -Version 5.1 | ||
Set-StrictMode -Version 'Latest' | ||
|
||
BeforeAll { | ||
Set-StrictMode -Version 'Latest' | ||
|
||
& (Join-Path -Path $PSScriptRoot -ChildPath 'Initialize-YodelTest.ps1' -Resolve) | ||
|
||
$script:conn = Get-YTMSSqlConnection | ||
$script:schemaName = 'get-ymssqltablecolumn' | ||
} | ||
|
||
Describe 'Get-YMsSqlTableColumn' { | ||
BeforeAll { | ||
GivenMSSqlSchema $script:schemaName | ||
} | ||
|
||
BeforeEach { | ||
$Global:Error.Clear() | ||
} | ||
|
||
AfterEach { | ||
} | ||
|
||
It 'gets columns' { | ||
GivenMSSqlTable 'get-ymssqltablecolumn_1' ` | ||
-Column @('id int not null', 'id2 nvarchar') ` | ||
-InSchema $script:schemaName | ||
$columns = Get-YMsSqlTableColumn -Connection $script:conn ` | ||
-SchemaName $script:schemaName ` | ||
-TableName 'get-ymssqltablecolumn_1' | ||
$columns | Should -Not -BeNullOrEmpty | ||
$columns | Should -HaveCount 2 | ||
$columns[0].name | Should -Be 'id' | ||
$columns[1].name | Should -Be 'id2' | ||
} | ||
|
||
It 'gets a column' { | ||
GivenMSSqlTable 'get-ymssqltablecolumn_2' -Column @('id3 int not null', 'id4 nvarchar') | ||
$column = Get-YMSSqlTableColumn -Connection $script:conn -TableName 'get-ymssqltablecolumn_2' -Name 'id3' | ||
$column | Should -Not -BeNullOrEmpty | ||
$column | Should -HaveCount 1 | ||
$column.name | Should -Be 'id3' | ||
} | ||
|
||
It 'validates table exists' { | ||
$result = Get-YMsSqlTableColumn -Connection $script:conn ` | ||
-TableName 'get-ymssqltablecolumn_3' ` | ||
-ErrorAction SilentlyContinue | ||
$result | Should -BeNullOrEmpty | ||
$Global:Error | Should -Match ([regex]::Escape('[dbo].[get-ymssqltablecolumn_3] does not exist')) | ||
} | ||
|
||
It 'validates column exists' { | ||
GivenMSSqlTable 'get-ymssqltablecolumn_4' -Column @('id5 int not null') | ||
$result = Get-YMsSqlTableColumn -Connection $script:conn ` | ||
-TableName 'get-ymssqltablecolumn_4' ` | ||
-Name 'id6' ` | ||
-ErrorAction SilentlyContinue | ||
$result | Should -BeNullOrEmpty | ||
$Global:Error | Should -Match 'Column \[id6\] does not exist' | ||
} | ||
|
||
It 'ignores errors' { | ||
GivenMSSqlTable 'get-ymssqltablecolumn_5' -Column @('id7 int not null') | ||
$result = Get-YMsSqlTableColumn -Connection $script:conn ` | ||
-TableName 'get-ymssqltablecolumn_5' ` | ||
-Name 'id8' ` | ||
-ErrorAction Ignore | ||
$result | Should -BeNullOrEmpty | ||
$Global:Error | Should -BeNullOrEmpty | ||
} | ||
} |
Oops, something went wrong.