mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-06-19 06:40:23 -07:00
mysql_query: fix false change reports when IF NOT EXISTS clause is used (#322)
* mysql_query: fix false change reports when IF NOT EXISTS clause is used * Fix * Fix doc, add fragment * Improve doc
This commit is contained in:
parent
ceda7662d0
commit
647461010d
3 changed files with 63 additions and 4 deletions
|
@ -321,6 +321,39 @@
|
|||
- result is changed
|
||||
- result.rowcount == [2]
|
||||
|
||||
# Issue https://github.com/ansible-collections/community.mysql/issues/268
|
||||
- name: Create table
|
||||
mysql_query:
|
||||
<<: *mysql_params
|
||||
login_db: '{{ test_db }}'
|
||||
query: "CREATE TABLE issue268 (id int)"
|
||||
single_transaction: yes
|
||||
|
||||
# Issue https://github.com/ansible-collections/community.mysql/issues/268
|
||||
- name: Create table with IF NOT EXISTS
|
||||
mysql_query:
|
||||
<<: *mysql_params
|
||||
login_db: '{{ test_db }}'
|
||||
query: "CREATE TABLE IF NOT EXISTS issue268 (id int)"
|
||||
single_transaction: yes
|
||||
register: result
|
||||
|
||||
# Issue https://github.com/ansible-collections/community.mysql/issues/268
|
||||
- assert:
|
||||
that:
|
||||
# PyMySQL driver throws a warning, so the following is correct
|
||||
- result is not changed
|
||||
when: connector.name.0 is search('pymysql')
|
||||
|
||||
# Issue https://github.com/ansible-collections/community.mysql/issues/268
|
||||
- assert:
|
||||
that:
|
||||
# mysqlclient driver throws nothing, so it's impossible to figure out
|
||||
# if the state was changed or not.
|
||||
# We assume that it was for DDL queryes by default in the code
|
||||
- result is changed
|
||||
when: connector.name.0 is search('mysqlclient')
|
||||
|
||||
- name: Drop db {{ test_db }}
|
||||
mysql_query:
|
||||
<<: *mysql_params
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue