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:
Andrew Klychkov 2020-11-03 15:04:39 +03:00 committed by GitHub
commit ae9c0a1751
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 69 additions and 5 deletions

View file

@ -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