Skip to content

Add Get/Set/Remove-DbaDbDataClassification commands#10301

Merged
potatoqualitee merged 4 commits intodevelopmentfrom
claude/issue-6316-20260403-1359
Apr 19, 2026
Merged

Add Get/Set/Remove-DbaDbDataClassification commands#10301
potatoqualitee merged 4 commits intodevelopmentfrom
claude/issue-6316-20260403-1359

Conversation

@andreasjordan
Copy link
Copy Markdown
Collaborator

Implements data classification support for SQL Server table columns (issue #6316).

Classification metadata is stored as extended properties compatible with SSMS Data Discovery & Classification and Azure SQL Database.

  • Get-DbaDbDataClassification: retrieves classifications from any database
  • Set-DbaDbDataClassification: upserts classifications with built-in MIP GUID mappings
  • Remove-DbaDbDataClassification: removes all classification properties from columns

Closes #6316

Generated with Claude Code

github-actions Bot and others added 3 commits April 3, 2026 14:10
Implements data classification support for SQL Server table columns.
Classification metadata is stored as extended properties (sys_information_type_id,
sys_information_type_name, sys_sensitivity_label_id, sys_sensitivity_label_name),
compatible with SSMS Data Discovery & Classification and Azure SQL Database.

- Get-DbaDbDataClassification: retrieves classifications from any database
- Set-DbaDbDataClassification: upserts classifications with built-in MIP GUID mappings
- Remove-DbaDbDataClassification: removes all classification properties from columns

Closes #6316

(do *DataClassification*)

Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.com>
@andreasjordan
Copy link
Copy Markdown
Collaborator Author

@claude Tests fail with:

Failed tests summary:
Path           : Get-DbaDbDataClassification/commands work as expected/finds classifications in a database
Name           : It finds classifications in a database
Result         : Failed
Message        : ErrorRecord: Expected 1, but got $null.
StackTrace     : 
RawErrorRecord : Expected 1, but got $null.

@claude
Copy link
Copy Markdown

claude Bot commented Apr 4, 2026

Claude finished @andreasjordan's task in 12m 28s —— View job


Test Failure Investigation

  • Read test file and implementation to understand failure
  • Identify root cause of Expected 1, but got $null
  • Verify fix was applied

Root Cause

The test failure was caused by using incorrect $TestConfig property names. The originally generated test code used $TestConfig.instance2 (which doesn't exist in TestConfig), then a first fix attempt used $TestConfig.SingleInstance (also wrong). The correct property is $TestConfig.InstanceSingle.

Why the specific error occurred:

  1. New-DbaDatabase -SqlInstance $null — with an undefined property, the SqlInstance was $null
  2. The BeforeAll setup failed silently or the extended properties were never created
  3. Get-DbaDbDataClassification returned $null (no classifications found)
  4. In Pester v5, $null | Should -Not -BeNullOrEmpty passes when $null is piped (quirky behaviour)
  5. $null.Count | Should -Be 1"Expected 1, but got $null"

Already Fixed

You already resolved this in your two fix tests commits:

  • e310ad3 — changed instance2SingleInstance (still wrong)
  • ad2c38a — changed SingleInstanceInstanceSingle (correct ✓)

All three test files now use $TestConfig.InstanceSingle. The removal of -Confirm:$false from test calls is also correct — $TestConfig.Defaults already sets '*-Dba*:Confirm' = $false globally for all tests.

No Further Changes Needed

The fix is correct. The tests should pass once run against a live SQL Server instance.

@andreasjordan
Copy link
Copy Markdown
Collaborator Author

The result has one element and is not an array, so testing for Count beeing 1 is not correct. Testing for not null is enought.

@andreasjordan andreasjordan marked this pull request as ready for review April 4, 2026 16:27
@potatoqualitee
Copy link
Copy Markdown
Member

Very nice, even takes care of the sql server minimum version, thank you 🙏🏼

@potatoqualitee potatoqualitee merged commit 3ed951f into development Apr 19, 2026
14 checks passed
@potatoqualitee potatoqualitee deleted the claude/issue-6316-20260403-1359 branch April 19, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Data classification

2 participants