Skip to content

Find-DbaObject - Add unified command to search database objects by name#10321

Draft
andreasjordan wants to merge 3 commits intodevelopmentfrom
claude/issue-9245-20260405-0932
Draft

Find-DbaObject - Add unified command to search database objects by name#10321
andreasjordan wants to merge 3 commits intodevelopmentfrom
claude/issue-9245-20260405-0932

Conversation

@andreasjordan
Copy link
Copy Markdown
Collaborator

Closes #9245

Adds Find-DbaObject, a unified command to search all database object types by name pattern, with optional column name searching.

What does this PR do?

  • Searches object names across tables, views, stored procedures, functions, synonyms, and triggers
  • Optionally searches column names with -IncludeColumns
  • Filter by object type with -ObjectType
  • Uses T-SQL against sys.objects and sys.columns for performance
  • Full regex support for pattern matching

Generated with Claude Code

github-actions bot and others added 2 commits April 5, 2026 09:44
Adds Find-DbaObject which searches all database object types (tables, views,
stored procedures, functions, synonyms, triggers) by name pattern, with optional
column name searching. Uses T-SQL against sys.objects and sys.columns for performance.

(do Find-DbaObject)

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

@claude one test is still failing:

Failed tests summary:
Path           : Find-DbaObject/System databases/Should include system databases when IncludeSystemDatabases is specified
Name           : It Should include system databases when IncludeSystemDatabases is specified
Result         : Failed
Message        : ErrorRecord: Expected a value, but got $null or empty.
StackTrace     : 
RawErrorRecord : Expected a value, but got $null or empty.
Uploading artifact DetailedTestFailures_Pester5.json (933 bytes)...100%

@claude
Copy link
Copy Markdown

claude bot commented Apr 6, 2026

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


Fixed failing test

  • Gather context
  • Read test file and function to identify the issue
  • Fix the failing test
  • Commit and push

Root cause: The test searched for syslogins (a system view in the master database) with IncludeSystemDatabases = $true, but the T-SQL query always filters AND o.is_ms_shipped = 0 unless IncludeSystemObjects is also set. Since syslogins has is_ms_shipped = 1, it was being excluded.

Fix: Added IncludeSystemObjects = $true to the test splat in tests/Find-DbaObject.Tests.ps1:229 so the test correctly finds the syslogins system view when searching system databases.
|

syslogins is a system view (is_ms_shipped=1) so IncludeSystemObjects
is required to find it alongside IncludeSystemDatabases.

(do Find-DbaObject)

Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.com>
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.

Find-DbaObject

1 participant