Skip to content

Commit a00f7b3

Browse files
authored
Added table schema to Get-DbaDbForeignKey (#9685)
1 parent 2c88f4c commit a00f7b3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

public/Get-DbaDbForeignKey.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,10 @@ function Get-DbaDbForeignKey {
116116
Add-Member -Force -InputObject $fk -MemberType NoteProperty -Name InstanceName -value $server.ServiceName
117117
Add-Member -Force -InputObject $fk -MemberType NoteProperty -Name SqlInstance -value $server.DomainInstanceName
118118
Add-Member -Force -InputObject $fk -MemberType NoteProperty -Name Database -value $db.Name
119+
Add-Member -Force -InputObject $fk -MemberType NoteProperty -Name Schema -Value $tbl.Schema
119120
Add-Member -Force -InputObject $fk -MemberType NoteProperty -Name Table -Value $tbl.Name
120121

121-
$defaults = 'ComputerName', 'InstanceName', 'SqlInstance', 'Database', 'Table', 'ID', 'CreateDate',
122+
$defaults = 'ComputerName', 'InstanceName', 'SqlInstance', 'Database', 'Schema', 'Table', 'ID', 'CreateDate',
122123
'DateLastModified', 'Name', 'IsEnabled', 'IsChecked', 'NotForReplication', 'ReferencedKey', 'ReferencedTable', 'ReferencedTableSchema'
123124
Select-DefaultView -InputObject $fk -Property $defaults
124125
}

tests/Get-DbaDbForeignKey.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" {
5353
Context "Parameters are returned correctly" {
5454
$results = Get-DbaDbForeignKey -SqlInstance $TestConfig.instance2 -ExcludeDatabase master
5555
It "Has the correct default properties" {
56-
$expectedStdProps = 'ComputerName,CreateDate,Database,DateLastModified,ID,InstanceName,IsChecked,IsEnabled,Name,NotForReplication,ReferencedKey,ReferencedTable,ReferencedTableSchema,SqlInstance,Table'.split(',')
56+
$expectedStdProps = 'ComputerName,CreateDate,Database,DateLastModified,ID,InstanceName,IsChecked,IsEnabled,Name,NotForReplication,ReferencedKey,ReferencedTable,ReferencedTableSchema,SqlInstance,Schema,Table'.split(',')
5757
($results[0].PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames | Sort-Object) | Should Be ($ExpectedStdProps | Sort-Object)
5858
}
5959
It "Has the correct properties" {
60-
$ExpectedProps = "Columns,ComputerName,CreateDate,Database,DatabaseEngineEdition,DatabaseEngineType,DateLastModified,DeleteAction,ExecutionManager,ExtendedProperties,ID,InstanceName,IsChecked,IsDesignMode,IsEnabled,IsFileTableDefined,IsMemoryOptimized,IsSystemNamed,Name,NotForReplication,Parent,ParentCollection,Properties,ReferencedKey,ReferencedTable,ReferencedTableSchema,ScriptReferencedTable,ScriptReferencedTableSchema,ServerVersion,SqlInstance,State,Table,UpdateAction,Urn,UserData".split(',')
60+
$ExpectedProps = "Columns,ComputerName,CreateDate,Database,DatabaseEngineEdition,DatabaseEngineType,DateLastModified,DeleteAction,ExecutionManager,ExtendedProperties,ID,InstanceName,IsChecked,IsDesignMode,IsEnabled,IsFileTableDefined,IsMemoryOptimized,IsSystemNamed,Name,NotForReplication,Parent,ParentCollection,Properties,ReferencedKey,ReferencedTable,ReferencedTableSchema,ScriptReferencedTable,ScriptReferencedTableSchema,ServerVersion,SqlInstance,State,Schema,Table,UpdateAction,Urn,UserData".split(',')
6161
($results[0].PsObject.Properties.Name | Sort-Object) | Should Be ($ExpectedProps | Sort-Object)
6262
}
6363
}

0 commit comments

Comments
 (0)