Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-DbaHelpIndex - Bad joins based on Index Name instead of Index ID when Indexes in same DB named the same #9447 #9473

Merged
merged 4 commits into from
Oct 5, 2024

Conversation

jianjunpei
Copy link
Contributor

Type of Change

Purpose

Fix #9447

Approach

Changed the sql code by adding a new where condition
Added a new unit test

Commands to test

.\tests\manual.pester.ps1 -Path .\tests\Get-DbaHelpIndex.Tests.ps1 -TestIntegration

The original function will fail the following new unit test.
Context Result is correct for tables having the indexes with the same names
[+] Table t1 has correct index key columns and included columns 7ms
[+] Table t2 has correct index key columns and included columns 12ms

Screenshots

Here is a simple reproducible test.
create a test database with tables having an index each with the same name.

create database test1;
go
use test1;
go
create table t1(c1 int,c2 int,c3 int,c4 int);
create nonclustered index idx_1 on t1(c1) include(c3);
create table t2(c1 int,c2 int,c3 int,c4 int);
create nonclustered index idx_1 on t2(c1,c2) include(c3,c4);
go

Run get-dbahelpindex to check.
For example:
get-dbahelpindex -sqlinstance 'localhost,14330' -database test1|out-gridview

The existing version returns the following result, which is wrong for both tables.
image

The proposed version returns the following result, which is correct.
image

Learning

@potatoqualitee
Copy link
Member

Thank you for your PR and your patience!

@potatoqualitee potatoqualitee merged commit 4d9fc65 into dataplat:development Oct 5, 2024
3 checks passed
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.

Get-DbaHelpIndex - Bad joins based on Index Name instead of Index ID when Indexes in same DB named the same
3 participants