-
Notifications
You must be signed in to change notification settings - Fork 225
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
SqlScript: Inconsistency in properties validation for some commands #1896
Comments
I just found a slight difference between a working server and a failing server: Working: I made the test... It's the root cause ! The new version 22.0.59 was just published yesterday... I'm very unlucky but that means You should ask for |
We do. In the template for "Problem with resource". 🙂
|
I saw that the new version of SqlServer was released so it might break stuff. It works with the preview version (22.0.49-preview), but apparently there are more breaking changes in this new release.
It should only pass in the parameter Variable if it is passed to the function. So it would need to be removed if it is not passed. if (-not $PSBoundParameters.ContainsKey('Variable'))
{
$PSBoundParameters.Remove('Variable')
} But instead of continue on with this "reverse-logic" it could be simplified to add parameters to a new hashtable that is passed to |
I can review a PR that fixes this if someone sends one in. |
- SqlServerDsc - Bump SqlServer version to 22.0.59 for integration tests for SQL Server 2022. - SqlServerDsc.Common - `Invoke-SqlScript` no longer passes the parameter `Variable` to `Invoke-SqlCmd` if it is not set (issue #1896). - `DatabasePermission` - Class was updated with the latest database permissions.
Problem description
Probably due to a change in a background lib (ps version or something else ?) a previous command which was working is not working anymore.
But that highlights an inconsistency in the script SqlScript parameters validation.
The
Variable
is optional but the script fails now if we don't define it.Verbose logs
How to reproduce
Nevermind the content of the sql files below the script below is now faling with logs above.
EDIT: You must use the version 22 of the module SqlServer
Install-Module SqlServer -RequiredVersion 22.0.59 -Force
Expected behavior
The script should pass with or without Variable defined.
Current behavior
By adding
Variable=@("test=test")
in script parameters that works.Refering to
(Get-CimClass -ClassName DSC_SqlScript -Namespace root\Microsoft\Windows\DesiredStateConfiguration).CimClassProperties | fl
The "Variable" option can be null
But the validation made by the powershell engine here is failing
SqlServerDsc/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1
Line 2090 in 4602416
Suggested solution
The powershell function
Invoke-SqlScript
should defaults to$null
for the argument$Variable
Does anyone has an idea why it is working on another server with the exact same module version, sql files, psversiontable, windows build version ?
Operating system the target node is running
PowerShell version and build the target node is running
Module version used
The text was updated successfully, but these errors were encountered: