-
Notifications
You must be signed in to change notification settings - Fork 1.7k
mssql_script: add tds_version and encryption parameters #10816
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
base: main
Are you sure you want to change the base?
mssql_script: add tds_version and encryption parameters #10816
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution!
I don't think this is related to #5693 though. Why do you think it is?
|
Also, please add a changelog fragment. Thanks. |
… None, update changelog
|
@felixfontein Thank you for your guidance! I have updated the code and the changelog. There is an issue in Issues that has the same error message as the one I encountered during my testing, but I am not sure if my update can resolve their problem. Therefore, I have removed the association for now. |
07a35a6 to
0266b75
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Halo1236 thanks for your contribution!
I've left a couple of comments, nothing major. Other than that, it LGTM
|
The test The test The test The test |
| description: | ||
| - Specify whether to use encryption for the connection to the server. | ||
| Please refer to the pymssql documentation for detailed information. | ||
| - The available values are "off" and "on" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - The available values are "off" and "on" | |
| - The available values are V("off") and V("on"). |
(I left the quotes to avoid conversion to booleans.)
If no other values are allowed, how about adding choices to limit the input to these two values?
| description: | ||
| - Specify the TDS protocol version to use when connecting to the server. | ||
| Please refer to the pymssql documentation for detailed information. | ||
| - The available values are "7.0", "7.1", "7.2", "7.3", "7.4", "8.0" etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - The available values are "7.0", "7.1", "7.2", "7.3", "7.4", "8.0" etc. | |
| - The available values are V(7.0), V(7.1), V(7.2), V(7.3), V(7.4), V(8.0), and so on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The param is type=str, the doc should recommend wrapping quotes, so that the values are not converted to float.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Halo1236 , thanks for your contribution.
Couple of comments.
| - Specify whether to use encryption for the connection to the server. | ||
| Please refer to the pymssql documentation for detailed information. | ||
| - The available values are "off" and "on" | ||
| type: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this is intrinsically a boolean value, why not:
| type: str | |
| type: bool |
?
Maybe it should have a default value, regardless of the type?
| description: | ||
| - Specify the TDS protocol version to use when connecting to the server. | ||
| Please refer to the pymssql documentation for detailed information. | ||
| - The available values are "7.0", "7.1", "7.2", "7.3", "7.4", "8.0" etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The param is type=str, the doc should recommend wrapping quotes, so that the values are not converted to float.
| login_port: "{{ mssql_port }}" | ||
| db: master | ||
| tds_version: "7.0" | ||
| encryption: off |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the param type=str, this should have quotes around the value. If you change it to type=bool, then
| encryption: off | |
| encryption: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Halo1236
A couple of additional comments. The PR is looking good, it just need these few adjustments.
If you are struggling with the tests, may I suggest giving a try to andebox, by yours truly:
https://pypi.org/project/andebox/
You can run this sanity test easily in your local machine by simply running:
$ andebox test -- sanity --docker default --python 3.13 plugins/modules/your_module.py
| Please refer to the pymssql documentation for detailed information. | ||
| - The available values are "off" and "on" | ||
| type: str | ||
| version_added: 11.4.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now:
| version_added: 11.4.0 | |
| version_added: 12.0.0 |
| params=dict(type='dict'), | ||
| transaction=dict(type='bool', default=False), | ||
| tds_version=dict(type='str'), | ||
| encryption=dict(type='str') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just making life better for the next person:
| encryption=dict(type='str') | |
| encryption=dict(type='str'), |
| "database": db, | ||
| } | ||
| if encryption is not None: | ||
| connection_args["encryption"] = encryption |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you make the parameter a boolean, then this should go:
| connection_args["encryption"] = encryption | |
| connection_args["encryption"] = "on" if encryption else "off" |
| - result_batches_dict.query_results_dict[0] | length == 2 # two selects in first batch | ||
| - result_batches_dict.query_results_dict[0][0] | length == 1 # one row in first select | ||
| - result_batches_dict.query_results_dict[0][0][0]['b0s0'] == 'Batch 0 - Select 0' # column 'b0s0' of first row | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is tripping the sanity test (trailing spaces in the line):
SUMMARY
This pull request adds support for specifying
tds_versionandencryptionoptions when connecting to Microsoft SQL Server in themssql_scriptAnsible module. These options improve compatibility with older SQL Server versions and allow more flexible connection configurations.Connection options enhancements:
tds_versionandencryption, to allow users to specify the TDS protocol version and encryption settings for SQL Server connections.tds_versionandencryptionparameters topymssql.connect, enabling these options to be used when establishing the database connection. [1] [2]ISSUE TYPE
COMPONENT NAME
mssql_script