mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-07-22 04:40:23 -07:00
mysql_query: fix failing when single-row query contains commas (#53)
* mysql_query: fix failing when single-row query contains commas * add changelog fragment * Improve documentation and tests * Fix typo * Improve test coverage * Fix * Remove the irrelevant note * change suggested
This commit is contained in:
parent
0dfd63a4cb
commit
ae9c0a1751
4 changed files with 69 additions and 5 deletions
|
@ -238,6 +238,57 @@
|
|||
that:
|
||||
- result.rowcount == [0]
|
||||
|
||||
- name: Create {{ test_table3 }}
|
||||
mysql_query:
|
||||
<<: *mysql_params
|
||||
login_db: '{{ test_db }}'
|
||||
query: 'CREATE TABLE {{ test_table3 }} (id int, story text)'
|
||||
|
||||
- name: Add data to {{ test_table3 }}
|
||||
mysql_query:
|
||||
<<: *mysql_params
|
||||
login_db: '{{ test_db }}'
|
||||
query: "INSERT INTO {{ test_table3 }} (id, story) VALUES (1, 'first'), (2, 'second')"
|
||||
|
||||
- name: Select from {{ test_table3 }}
|
||||
mysql_query:
|
||||
<<: *mysql_params
|
||||
login_db: '{{ test_db }}'
|
||||
query: 'SELECT id, story FROM {{ test_table3 }}'
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.rowcount == [2]
|
||||
|
||||
- name: Pass wrong query type
|
||||
mysql_query:
|
||||
<<: *mysql_params
|
||||
login_db: '{{ test_db }}'
|
||||
query: {'this type is': 'wrong'}
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 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 }}
|
||||
mysql_query:
|
||||
<<: *mysql_params
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue