diff --git a/.github/workflows/build-validation.yml b/.github/workflows/build-validation.yml index 20366e2..d45c99a 100644 --- a/.github/workflows/build-validation.yml +++ b/.github/workflows/build-validation.yml @@ -1,6 +1,6 @@ on: push: - branches: [ develop, bugfix/*, feature/*, release/* ] + branches: [ develop, bugfix/*, feature/*, release/*, hotfix/* ] pull_request: branches: [ develop ] diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 40324ba..b303c66 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -1,6 +1,6 @@ on: push: - branches: [ release/* ] + branches: [ release/*, hotfix/* ] workflow_dispatch: jobs: diff --git a/.vscode/settings.json b/.vscode/settings.json index 18aa29a..a182eab 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,6 +3,8 @@ "cSpell.words": [ "dacpac", "Filegroups", + "Hashtable", + "Nocheck", "sqlproj", "Ssdt", "testdb" diff --git a/.vscode/tasks.json b/.vscode/tasks.json index f7f0d70..9976358 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -89,5 +89,20 @@ }, "dependsOn": ["Build", "Create Testdata"] }, + { + "label": "Test exclude AzureSql", + "group": "test", + "type": "shell", + "command": "Invoke-Pester -Configuration @{ Filter = @{ ExcludeTag = 'AzureSql' }}", + "options": { + "cwd": "test" + }, + "problemMatcher": "$msCompile", + "presentation": { + "echo": false, + "showReuseMessage": false + }, + "dependsOn": ["Build"] + }, ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 478c6e5..dcf5956 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.7.0] - 2024-08-13 + +### Changed + +- Added support for views to `Get-DacColumn` command. +- Updated Microsoft.SqlServer.DacFx to 162.1.167. +- Updated System.Management.Automation to 7.2.16 and PowerShell 7.2.16. + +### Added + +- Added `Install-Package` parameter for IgnoreWithNocheckOnCheckConstraints, IgnoreWithNocheckOnForeignKeys and ScriptNewConstraintValidation. + ## [1.6.0] - 2023-08-24 ### Changed diff --git a/PsDac.sln b/PsDac.sln new file mode 100644 index 0000000..cfd0b90 --- /dev/null +++ b/PsDac.sln @@ -0,0 +1,30 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E3CF8094-3455-46A9-B9D3-FBBCA943E40A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PsDac", "src\PsDac\PsDac.csproj", "{1E0D293B-B68C-401E-988D-4B8CD72F5CB4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1E0D293B-B68C-401E-988D-4B8CD72F5CB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1E0D293B-B68C-401E-988D-4B8CD72F5CB4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1E0D293B-B68C-401E-988D-4B8CD72F5CB4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1E0D293B-B68C-401E-988D-4B8CD72F5CB4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {1E0D293B-B68C-401E-988D-4B8CD72F5CB4} = {E3CF8094-3455-46A9-B9D3-FBBCA943E40A} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2D4E4A93-6CA1-487D-96A9-267F1FF4B072} + EndGlobalSection +EndGlobal diff --git a/docs/Get-DacColumn.md b/docs/Get-DacColumn.md index 10db711..4612904 100644 --- a/docs/Get-DacColumn.md +++ b/docs/Get-DacColumn.md @@ -8,12 +8,12 @@ schema: 2.0.0 # Get-DacColumn ## SYNOPSIS -Returns columns of a table. +Returns columns of a table or view. ## SYNTAX ``` -Get-DacColumn [-Table] [[-Name] ] [] +Get-DacColumn -Object [[-Name] ] [] ``` ## DESCRIPTION @@ -30,6 +30,15 @@ Schema Name ObjectType Application [Application].[Cities].[CityID] Microsoft.SqlServer.Dac.Model.ModelTypeClass ``` +### Example 2 +``` +PS C:\> Import-DacModel -Path ./WideWorldImporters.dacpac | Get-DacView -Name '[Website].[Customers]' | Get-DacColumn -Name '[Website].[Customers].[CustomerID]' + +Schema Name ObjectType +------ ---- ---------- +Website [Website].[Customers].[CustomerID] Microsoft.SqlServer.Dac.Model.ModelTypeClass +``` + ## PARAMETERS ### -Name @@ -47,17 +56,17 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Table -Specifies the table to get the columns from. -The ObjectType must be Table. +### -Object +Specifies the table or view to get the columns from. +The ObjectType must be Table or View. ```yaml Type: TSqlObject Parameter Sets: (All) -Aliases: +Aliases: Table Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False diff --git a/docs/Install-DacPackage.md b/docs/Install-DacPackage.md index 8ad8eb4..5b743cb 100644 --- a/docs/Install-DacPackage.md +++ b/docs/Install-DacPackage.md @@ -37,29 +37,13 @@ Installs the content of myDb.dacpac into database myDb on localdb and creates th ## PARAMETERS -### -DatabaseName -Specifies the database to install the package into. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ExcludeObjectTypes -List of ObjectType, that must not be installed. +### -AcceptPossibleDataLoss +{{ Fill AcceptPossibleDataLoss Description }} ```yaml -Type: ObjectType[] +Type: SwitchParameter Parameter Sets: (All) Aliases: -Accepted values: Aggregates, ApplicationRoles, Assemblies, AssemblyFiles, AsymmetricKeys, BrokerPriorities, Certificates, ColumnEncryptionKeys, ColumnMasterKeys, Contracts, DatabaseOptions, DatabaseRoles, DatabaseTriggers, Defaults, ExtendedProperties, ExternalDataSources, ExternalFileFormats, ExternalTables, Filegroups, Files, FileTables, FullTextCatalogs, FullTextStoplists, MessageTypes, PartitionFunctions, PartitionSchemes, Permissions, Queues, RemoteServiceBindings, RoleMembership, Rules, ScalarValuedFunctions, SearchPropertyLists, SecurityPolicies, Sequences, Services, Signatures, StoredProcedures, SymmetricKeys, Synonyms, Tables, TableValuedFunctions, UserDefinedDataTypes, UserDefinedTableTypes, ClrUserDefinedTypes, Users, Views, XmlSchemaCollections, Audits, Credentials, CryptographicProviders, DatabaseAuditSpecifications, DatabaseEncryptionKeys, DatabaseScopedCredentials, Endpoints, ErrorMessages, EventNotifications, EventSessions, LinkedServerLogins, LinkedServers, Logins, MasterKeys, Routes, ServerAuditSpecifications, ServerRoleMembership, ServerRoles, ServerTriggers, ExternalStreams, ExternalStreamingJobs, DatabaseWorkloadGroups, WorkloadClassifiers, ExternalLibraries, ExternalLanguages Required: False Position: Named @@ -68,27 +52,11 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Package -Specifies the package to install into the database. - -```yaml -Type: DacPackage -Parameter Sets: (All) -Aliases: - -Required: True -Position: 0 -Default value: None -Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False -``` - -### -Service -Specifies the server to install the package to. -Default is the latest connected service. +### -CommandTimeout +{{ Fill CommandTimeout Description }} ```yaml -Type: DacServices +Type: Int32 Parameter Sets: (All) Aliases: @@ -99,23 +67,8 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -UpgradeExisting -{{ Fill upgradeExisting Description }} - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -CommandTimeout -{{ Fill CommandTimeout Description }} +### -DatabaseLockTimeout +{{ Fill DatabaseLockTimeout Description }} ```yaml Type: Int32 @@ -129,18 +82,18 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -DatabaseLockTimeout -{{ Fill DatabaseLockTimeout Description }} +### -DatabaseName +Specifies the database to install the package into. ```yaml -Type: Int32 +Type: String Parameter Sets: (All) Aliases: -Required: False +Required: True Position: Named Default value: None -Accept pipeline input: False +Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` @@ -151,6 +104,7 @@ Accept wildcard characters: False Type: ObjectType[] Parameter Sets: (All) Aliases: +Accepted values: Aggregates, ApplicationRoles, Assemblies, AssemblyFiles, AsymmetricKeys, BrokerPriorities, Certificates, ColumnEncryptionKeys, ColumnMasterKeys, Contracts, DatabaseOptions, DatabaseRoles, DatabaseTriggers, Defaults, ExtendedProperties, ExternalDataSources, ExternalFileFormats, ExternalTables, Filegroups, Files, FileTables, FullTextCatalogs, FullTextStoplists, MessageTypes, PartitionFunctions, PartitionSchemes, Permissions, Queues, RemoteServiceBindings, RoleMembership, Rules, ScalarValuedFunctions, SearchPropertyLists, SecurityPolicies, Sequences, Services, Signatures, StoredProcedures, SymmetricKeys, Synonyms, Tables, TableValuedFunctions, UserDefinedDataTypes, UserDefinedTableTypes, ClrUserDefinedTypes, Users, Views, XmlSchemaCollections, Audits, Credentials, CryptographicProviders, DatabaseAuditSpecifications, DatabaseEncryptionKeys, DatabaseScopedCredentials, Endpoints, ErrorMessages, EventNotifications, EventSessions, LinkedServerLogins, LinkedServers, Logins, MasterKeys, Routes, ServerAuditSpecifications, ServerRoleMembership, ServerRoles, ServerTriggers, ExternalStreams, ExternalStreamingJobs, DatabaseWorkloadGroups, WorkloadClassifiers, ExternalLibraries, ExternalLanguages Required: False Position: Named @@ -279,6 +233,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -ExcludeObjectTypes +List of ObjectType, that must not be installed. + +```yaml +Type: ObjectType[] +Parameter Sets: (All) +Aliases: +Accepted values: Aggregates, ApplicationRoles, Assemblies, AssemblyFiles, AsymmetricKeys, BrokerPriorities, Certificates, ColumnEncryptionKeys, ColumnMasterKeys, Contracts, DatabaseOptions, DatabaseRoles, DatabaseTriggers, Defaults, ExtendedProperties, ExternalDataSources, ExternalFileFormats, ExternalTables, Filegroups, Files, FileTables, FullTextCatalogs, FullTextStoplists, MessageTypes, PartitionFunctions, PartitionSchemes, Permissions, Queues, RemoteServiceBindings, RoleMembership, Rules, ScalarValuedFunctions, SearchPropertyLists, SecurityPolicies, Sequences, Services, Signatures, StoredProcedures, SymmetricKeys, Synonyms, Tables, TableValuedFunctions, UserDefinedDataTypes, UserDefinedTableTypes, ClrUserDefinedTypes, Users, Views, XmlSchemaCollections, Audits, Credentials, CryptographicProviders, DatabaseAuditSpecifications, DatabaseEncryptionKeys, DatabaseScopedCredentials, Endpoints, ErrorMessages, EventNotifications, EventSessions, LinkedServerLogins, LinkedServers, Logins, MasterKeys, Routes, ServerAuditSpecifications, ServerRoleMembership, ServerRoles, ServerTriggers, ExternalStreams, ExternalStreamingJobs, DatabaseWorkloadGroups, WorkloadClassifiers, ExternalLibraries, ExternalLanguages + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -LongRunningCommandTimeout {{ Fill LongRunningCommandTimeout Description }} @@ -294,11 +264,27 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Variables -{{ Fill Variables Description }} +### -Package +Specifies the package to install into the database. ```yaml -Type: Hashtable +Type: DacPackage +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: False +``` + +### -Service +Specifies the server to install the package to. +Default is the latest connected service. + +```yaml +Type: DacServices Parameter Sets: (All) Aliases: @@ -309,14 +295,29 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -AcceptPossibleDataLoss -{{ Fill AcceptPossibleDataLoss Description }} +### -UpgradeExisting +{{ Fill upgradeExisting Description }} ```yaml Type: SwitchParameter Parameter Sets: (All) Aliases: +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Variables +{{ Fill Variables Description }} + +```yaml +Type: Hashtable +Parameter Sets: (All) +Aliases: + Required: False Position: Named Default value: None diff --git a/src/PsDac/GetColumnCommand.cs b/src/PsDac/GetColumnCommand.cs index e15af9b..a3a19f2 100644 --- a/src/PsDac/GetColumnCommand.cs +++ b/src/PsDac/GetColumnCommand.cs @@ -7,13 +7,14 @@ namespace PsDac [OutputType(typeof(TSqlObject))] public class GetColumnCommand : PSCmdlet { + [Alias("Table")] [Parameter( Position = 0, Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)] [ValidateNotNullOrEmpty()] - public TSqlObject Table { get; set; } + public TSqlObject Object { get; set; } [Parameter( Position = 1, @@ -25,8 +26,8 @@ protected override void ProcessRecord() { base.ProcessRecord(); - if (Table.ObjectType.Name != "Table") { - throw new System.ArgumentException("Invalid Table type", Table.ObjectType.Name); + if (Object.ObjectType.Name != "Table" && Object.ObjectType.Name != "View") { + throw new System.ArgumentException("Invalid Table or View type", Object.ObjectType.Name); } bool hasNameFilter = Name != null; @@ -34,7 +35,9 @@ protected override void ProcessRecord() WriteVerbose($"Filter columns on name '{Name}'"); } - foreach (var item in Table.GetReferencedRelationshipInstances(Microsoft.SqlServer.Dac.Model.Table.Columns, DacQueryScopes.Default)) { + var relationship = Object.ObjectType.Name == "Table" ? Microsoft.SqlServer.Dac.Model.Table.Columns : Microsoft.SqlServer.Dac.Model.View.Columns; + + foreach (var item in Object.GetReferencedRelationshipInstances(relationship, DacQueryScopes.Default)) { if ( ( !hasNameFilter || item.ObjectName.ToString() == Name )) { var result = new PSObject(item.Object); diff --git a/src/PsDac/InstallPackageCommand.cs b/src/PsDac/InstallPackageCommand.cs index 73610f6..97f58df 100644 --- a/src/PsDac/InstallPackageCommand.cs +++ b/src/PsDac/InstallPackageCommand.cs @@ -59,6 +59,24 @@ public Hashtable Variables } } + [Parameter()] + public SwitchParameter IgnoreWithNocheckOnForeignKeys + { + set { DeployOptions.IgnoreWithNocheckOnForeignKeys = value.IsPresent; } + } + + [Parameter()] + public SwitchParameter IgnoreWithNocheckOnCheckConstraints + { + set { DeployOptions.IgnoreWithNocheckOnCheckConstraints = value.IsPresent; } + } + + [Parameter()] + public SwitchParameter SkipNewConstraintValidation + { + set { DeployOptions.ScriptNewConstraintValidation = !value.IsPresent; } + } + #region Timeouts [Parameter()] diff --git a/src/PsDac/PsDac.csproj b/src/PsDac/PsDac.csproj index 0d54dc5..33f7cb8 100644 --- a/src/PsDac/PsDac.csproj +++ b/src/PsDac/PsDac.csproj @@ -6,9 +6,9 @@ - + + - diff --git a/src/PsDac/PsDac.psd1 b/src/PsDac/PsDac.psd1 index 91e7fa8..223061a 100644 --- a/src/PsDac/PsDac.psd1 +++ b/src/PsDac/PsDac.psd1 @@ -12,7 +12,7 @@ RootModule = 'PsDac.psm1' # Version number of this module. - ModuleVersion = '1.6.0' + ModuleVersion = '1.7.0' # Supported PSEditions # CompatiblePSEditions = @() @@ -33,7 +33,7 @@ Description = 'PsDac connects DacFx and PowerShell. It gives you PowerShell Cmdlets with the power of Microsoft.SqlServer.DacFx.' # Minimum version of the PowerShell engine required by this module - PowerShellVersion = '7.2.10' + PowerShellVersion = '7.2.16' # Name of the PowerShell host required by this module # PowerShellHostName = '' diff --git a/src/PsDac/PsDac.psm1 b/src/PsDac/PsDac.psm1 index 186168f..9e3ecb2 100644 --- a/src/PsDac/PsDac.psm1 +++ b/src/PsDac/PsDac.psm1 @@ -1,44 +1,46 @@ -$LoadedAssemblies = [System.AppDomain]::CurrentDomain.GetAssemblies() - -@( - "$PSScriptRoot/Azure.Core.dll", - "$PSScriptRoot/Azure.Identity.dll", - "$PSScriptRoot/Microsoft.Identity.Client.dll", - "$PSScriptRoot/Microsoft.SqlServer.Server.dll", - "$PSScriptRoot/runtimes/win/lib/netcoreapp3.1/Microsoft.Data.SqlClient.dll" - ) | ForEach-Object { - [System.IO.FileInfo] $RequiredAssemblyPath = $_ - If ( -not $RequiredAssemblyPath.Exists ) { - Write-Error "Build issue: '$RequiredAssemblyPath' does not exist." - } - $LoadedAssembly = $LoadedAssemblies | Where-Object Location -Like "*$( $RequiredAssemblyPath.Name )" - - if ( $LoadedAssembly ) { - if ( $LoadedAssembly.Location -ne $RequiredAssemblyPath.FullName ) { - Write-Warning "Assembly '$( $LoadedAssembly.GetName() )' already loaded from '$( $LoadedAssembly.Location )'. Skip adding defined dll." - } - } - else { - try { - # Microsoft.Data.SqlClient.dll expects Data.SqlClient.SNI.dll in the same directory - copy Data.SqlClient.SNI.dll before adding SqlClient - if ( $RequiredAssemblyPath.Name -eq 'Microsoft.Data.SqlClient.dll' ) - { - $Runtime = switch ($Env:PROCESSOR_ARCHITECTURE) - { - AMD64 { 'win-x64' } - X86 { 'win-x86' } - Arm { 'win-arm' } - } - $NativeDllTargetDirectory = "$PSScriptRoot/runtimes/win/lib/netcoreapp3.1" - if ( -Not ( Test-Path "$NativeDllTargetDirectory/Microsoft.Data.SqlClient.SNI.dll" ) ) { - Copy-Item "$PSScriptRoot/runtimes/$Runtime/native/Microsoft.Data.SqlClient.SNI.dll" -Destination $NativeDllTargetDirectory - } - } - - Add-Type -Path $RequiredAssemblyPath - } - catch [System.IO.FileLoadException] { - Write-Error "$( $_.Exception ) while adding assembly '$( $RequiredAssemblyPath.Name )'" - } - } - } +$LoadedAssemblies = [System.AppDomain]::CurrentDomain.GetAssemblies() + +@( + "$PSScriptRoot/Azure.Core.dll", + "$PSScriptRoot/Azure.Identity.dll", + "$PSScriptRoot/Microsoft.Identity.Client.dll", + "$PSScriptRoot/Microsoft.SqlServer.Server.dll", + "$PSScriptRoot/runtimes/win/lib/net6.0/Microsoft.Data.SqlClient.dll" + ) | ForEach-Object { + [System.IO.FileInfo] $RequiredAssemblyPath = $_ + If ( -not $RequiredAssemblyPath.Exists ) { + Write-Error "Build issue: '$RequiredAssemblyPath' does not exist." + } + $LoadedAssembly = $LoadedAssemblies | Where-Object Location -Like "*$( $RequiredAssemblyPath.Name )" + + if ( $LoadedAssembly ) { + if ( $LoadedAssembly.Location -ne $RequiredAssemblyPath.FullName ) { + Write-Warning "Assembly '$( $LoadedAssembly.GetName() )' already loaded from '$( $LoadedAssembly.Location )'. Skip adding defined dll." + } + } + else { + try { + # Microsoft.Data.SqlClient.dll expects Data.SqlClient.SNI.dll in the same directory - copy Data.SqlClient.SNI.dll before adding SqlClient + if ( $RequiredAssemblyPath.Name -eq 'Microsoft.Data.SqlClient.dll' ) + { + $Runtime = switch ($Env:PROCESSOR_ARCHITECTURE) + { + AMD64 { 'win-x64' } + X86 { 'win-x86' } + Arm { 'win-arm' } + } + if ( $Runtime ) { + $NativeDllTargetDirectory = "$PSScriptRoot/runtimes/win/lib/net6.0" + if ( -Not ( Test-Path "$NativeDllTargetDirectory/Microsoft.Data.SqlClient.SNI.dll" ) ) { + Copy-Item "$PSScriptRoot/runtimes/$Runtime/native/Microsoft.Data.SqlClient.SNI.dll" -Destination $NativeDllTargetDirectory + } + } + } + + Add-Type -Path $RequiredAssemblyPath + } + catch [System.IO.FileLoadException] { + Write-Error "$( $_.Exception ) while adding assembly '$( $RequiredAssemblyPath.Name )'" + } + } + } diff --git a/test/Connect-Service.Tests.ps1 b/test/Connect-Service.Tests.ps1 index 6b9f993..bfc7e9e 100644 --- a/test/Connect-Service.Tests.ps1 +++ b/test/Connect-Service.Tests.ps1 @@ -34,7 +34,7 @@ Describe Connect-Service { } } - Context AzureSqlServer -Tag Azure { + Context AzureSqlServer -Tag AzureSql { BeforeAll { $TestServer = New-SqlTestAzureInstance -Subscription 'Visual Studio' -ErrorAction Stop diff --git a/test/Get-Column.Tests.ps1 b/test/Get-Column.Tests.ps1 index 0639c72..a19295a 100644 --- a/test/Get-Column.Tests.ps1 +++ b/test/Get-Column.Tests.ps1 @@ -20,17 +20,51 @@ Describe Get-Column { $Table = $Model | Get-DacTable -Name '[Application].[Cities]' } - It 'Returns all columns of a table' { + It 'Returns all columns of a table via unnamed parameter' { $Columns = $Table | Get-DacColumn $Columns | Should -Not -BeNullOrEmpty $Columns.Count | Should -BeGreaterThan 3 } + It 'Returns all columns of a table via named parameter' { + $Columns = Get-DacColumn -Object $Table + $Columns | Should -Not -BeNullOrEmpty + $Columns.Count | Should -BeGreaterThan 3 + } + + It 'Returns all columns of a table via aliased parameter' { + $Columns = Get-DacColumn -Table $Table + $Columns | Should -Not -BeNullOrEmpty + $Columns.Count | Should -BeGreaterThan 3 + } + It 'Returns a column of a table by name' { $Column = $Table | Get-DacColumn -Name '[Application].[Cities].[CityID]' $Column | Should -Not -BeNullOrEmpty } } + Context 'View' { + BeforeAll { + $View = $Model | Get-DacView -Name '[Website].[Customers]' + } + + It 'Returns all columns of a view via unnamed parameter' { + $Columns = $View | Get-DacColumn + $Columns | Should -Not -BeNullOrEmpty + $Columns.Count | Should -BeGreaterThan 3 + } + + It 'Returns all columns of a view via named parameter' { + $Columns = Get-DacColumn -Object $View + $Columns | Should -Not -BeNullOrEmpty + $Columns.Count | Should -BeGreaterThan 3 + } + + It 'Returns a column of a view by name' { + $Column = $View | Get-DacColumn -Name '[Website].[Customers].[CustomerID]' + $Column | Should -Not -BeNullOrEmpty + } + } } } } diff --git a/test/sql-server-samples b/test/sql-server-samples index 0240d92..68db902 160000 --- a/test/sql-server-samples +++ b/test/sql-server-samples @@ -1 +1 @@ -Subproject commit 0240d924fc7cf339696e4da90fbfea49671d41d0 +Subproject commit 68db9029ba9e893365a7022c1d2262f5b5cf6ca2