-
Notifications
You must be signed in to change notification settings - Fork 224
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
SqlQuery: New resource proposal #1920
Comments
I like the idea of combing into a single resource. I do have two comments after reading this
|
My thought that the parameter were not needed if we move away from using
I agree that it is probably better to control the two independently. We should also move the logic in |
Okay, this should be straight forward just execute the string.
Not quite sure I follow what this would look like with the proposed resource. I use the variable feature as often as possible to simplify and reuse scripts across multiple resources. Here is a simple example Existing DSC Resource Example
T-SQL getScript.sql from above file
I realize there are a few ways to handle substitution or string building in PowerShell natively, but in the context of the proposed resource I'm not sure what that looks like. Is the expectation that you'd just handle that outside the resource completely?
I wasn't sure if it would be best to lump it in with this proposal, but it is related and might be as good a time as any other to improve both. |
Ah, for files then the Variable would be a necessity, then we can't parse the strings in the configuration that we can do for the string that is passed to the suggested parameter I guess we then need parameter So in the example would instead look like this:
Then, since the parameter
to
Would that work? |
Would it be a problem parsing some of the variables depending on the data type or can all be made strings so they are converted automatically by SQL Server? 🤔 I feel it was a long time since I manipulated data types in T-SQL 🙂 |
Resource proposal
Suggest adding a new class-based resource SqlQuery that will deprecate SqlScript and SqlScriptQuery.
Proposed properties
'MSSQLSERVER'
.Get
was called.Special considerations or limitations
As mentioned in the comment #1904 (comment) it would help using different modules that provides the SMO assemblies if this module is not dependent on a specific command from a specific module (that also is dependent on SMO assemblies).
The new resource should use the command
Invoke-SqlDscQuery
. ForGet()
andTest
it will pass thePassThru
parameter to return the expected values. ForSet()
it will not pass the parameterPassThru
since it will just execute and do not return any values.If possible the T-SQL statement
PRINT
should be outputted as verbose messages (similar to whatInvoke-SqlCmd
does). This might require changes toInvoke-SqlDscQuery
.It should not be possible to specify both a query string and a query file for the same method, e.g.
GetQuery
andGetQueryFilePath
. But it should be possible to specifyGetQuery
andTestQueryFilePath
.It should throw an exception if a method (
Get(),
Set(), or
Test`) is called without having any of the Query parameters assigned.Might be worth skipping the parameter
Variable
in a first iteration of the resource so more feedback can be gathered. 🤔The text was updated successfully, but these errors were encountered: