mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-13 06:00:33 -07:00
change suggested
This commit is contained in:
parent
faf4469432
commit
4189c430a6
2 changed files with 23 additions and 3 deletions
plugins/modules
tests/integration/targets/test_mysql_query/tasks
|
@ -20,7 +20,7 @@ options:
|
||||||
query:
|
query:
|
||||||
description:
|
description:
|
||||||
- SQL query to run. Multiple queries can be passed using YAML list syntax.
|
- SQL query to run. Multiple queries can be passed using YAML list syntax.
|
||||||
- Must be a string or YAML list.
|
- Must be a string or YAML list containing strings.
|
||||||
type: raw
|
type: raw
|
||||||
required: yes
|
required: yes
|
||||||
positional_args:
|
positional_args:
|
||||||
|
@ -149,6 +149,13 @@ def main():
|
||||||
if not isinstance(query, str) and not isinstance(query, list):
|
if not isinstance(query, str) and not isinstance(query, list):
|
||||||
module.fail_json(msg="the query option value must be a string or list, passed %s" % type(query))
|
module.fail_json(msg="the query option value must be a string or list, passed %s" % type(query))
|
||||||
|
|
||||||
|
if isinstance(query, str):
|
||||||
|
query = [query]
|
||||||
|
|
||||||
|
for elem in query:
|
||||||
|
if not isinstance(elem, str):
|
||||||
|
module.fail_json(msg="the elements in query list must be strings, passed '%s' %s" % (elem, type(elem)))
|
||||||
|
|
||||||
if module.params["single_transaction"]:
|
if module.params["single_transaction"]:
|
||||||
autocommit = False
|
autocommit = False
|
||||||
else:
|
else:
|
||||||
|
@ -185,8 +192,6 @@ def main():
|
||||||
query_result = []
|
query_result = []
|
||||||
executed_queries = []
|
executed_queries = []
|
||||||
rowcount = []
|
rowcount = []
|
||||||
if isinstance(query, str):
|
|
||||||
query = [query]
|
|
||||||
|
|
||||||
for q in query:
|
for q in query:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -274,6 +274,21 @@
|
||||||
- result is failed
|
- result is failed
|
||||||
- result.msg is search('the query option value must be a string or list')
|
- result.msg is search('the query option value must be a string or list')
|
||||||
|
|
||||||
|
- name: Pass wrong query element
|
||||||
|
mysql_query:
|
||||||
|
<<: *mysql_params
|
||||||
|
login_db: '{{ test_db }}'
|
||||||
|
query:
|
||||||
|
- 'SELECT now()'
|
||||||
|
- {'this type is': 'wrong'}
|
||||||
|
register: result
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- result is failed
|
||||||
|
- result.msg is search('the elements in query list must be strings')
|
||||||
|
|
||||||
- name: Drop db {{ test_db }}
|
- name: Drop db {{ test_db }}
|
||||||
mysql_query:
|
mysql_query:
|
||||||
<<: *mysql_params
|
<<: *mysql_params
|
||||||
|
|
Loading…
Add table
Reference in a new issue