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

Test-DbaDbCompatibility - Determining target compatibility level based on server version #8992

Merged
merged 1 commit into from
Jun 22, 2023

Conversation

andreasjordan
Copy link
Contributor

Type of Change

  • Bug fix (non-breaking change, fixes Test-DbaDbCompatibility - Don't trust the compatibility level of the master database #8991 )
  • New feature (non-breaking change, adds functionality, fixes # )
  • Breaking change (affects multiple commands or functionality, fixes # )
  • Ran manual Pester test and has passed (.\tests\manual.pester.ps1)
  • Adding code coverage to existing functionality
  • Pester test is included
  • If new file reference added for test, has is been added to github.com/dataplat/appveyor-lab ?
  • Unit test is included
  • Documentation
  • Build system

See issue for details.

@@ -77,7 +77,8 @@ function Test-DbaDbCompatibility {
Stop-Function -Message "Failure" -Category ConnectionError -ErrorRecord $_ -Target $instance -Continue
}

$serverLevel = [Microsoft.SqlServer.Management.Smo.CompatibilityLevel]$server.Databases['master'].CompatibilityLevel
$serverVersion = $server.VersionMajor
$serverLevel = [Microsoft.SqlServer.Management.Smo.CompatibilityLevel]"Version$($serverVersion)0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is itching for bugs to show up if we start assuming it will always be a zero on the end. That is why we use master database.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what was being done in Set command as well and it was removed because it is unsafe method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we need two internal commands the have a rubust way to translate from MajorVersion to CompatibilityLevel and vice versa. I agree with that. We could then use this in many places...
The question is: Is there an "arithmetic rule" or do we need a switch with hard coded values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still confused on why we think it is necessary to translate between MajorVersion and Compatibility level. If there was a reason for that then SMO should provide it not us because we are assuming we know the mapping. If we are going to keep a mapping then revert the changes done in Set command and replace that use everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Test-DbaDbCompatibility (Compares Database Compatibility level to Server Compatibility) we need to know the highest possible Compatibility level on that server. So we have the server SMO and need that highest possible Compatibility level. Where do we get that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to know the highest possible value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the test command should tell me, if the database is in the highest possible Compatibility level. Or don't we agree on that one?
And tempdb as well can be set on a different level, so can not be used.

@potatoqualitee potatoqualitee merged commit e547035 into development Jun 22, 2023
@potatoqualitee potatoqualitee deleted the TestDbaDbCompatibility_fix_8991 branch June 22, 2023 13:33
@potatoqualitee
Copy link
Member

LGTM

@potatoqualitee
Copy link
Member

merciiii

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.

Test-DbaDbCompatibility - Don't trust the compatibility level of the master database
3 participants