ansible-for-i icon indicating copy to clipboard operation
ansible-for-i copied to clipboard

SQL is converted to uppercase prior to execution

Open martintosney opened this issue 4 years ago • 2 comments

ISSUE

The ibmi_sql_execute and ibmi_sql_query modules convert the SQL to uppercase prior to execution. This will cause a problem for any query that uses string literals.

EXAMPLE

Take a task like the following:

- ibmi_sql_execute:
    sql: >
      INSERT INTO mytable (key, value)
      VALUES('KEY', 'Value')

I would actually end up with a row that looks like this:

key value
KEY VALUE

Instead of the expected:

key value
KEY Value

FIX

I think this is as straightforward as removing the .upper() for the sql in these two modules:

https://github.com/IBM/ansible-for-i/blob/5c6d28b7909faa4d191d8df777737baf9834ebde/plugins/modules/ibmi_sql_execute.py#L167 https://github.com/IBM/ansible-for-i/blob/5c6d28b7909faa4d191d8df777737baf9834ebde/plugins/modules/ibmi_sql_query.py#L202

If you would like me to submit a pull request, please let me know!

martintosney avatar Jan 11 '21 16:01 martintosney

Thanks for testing this, I will fix it. Thanks!

changlexc avatar Jan 12 '21 02:01 changlexc

I think this issue is present in other modules as well. Like https://github.com/IBM/ansible-for-i/blob/5c6d28b7909faa4d191d8df777737baf9834ebde/plugins/modules/ibmi_user_and_group.py#L296 (User text / description is converted to uppercase) or https://github.com/IBM/ansible-for-i/blob/5c6d28b7909faa4d191d8df777737baf9834ebde/plugins/modules/ibmi_user_and_group.py#L297 (all parameters are converted to uppercase -> might cause problems with HOMEDIR & ACTCDE)

wolfipa avatar Jun 11 '21 15:06 wolfipa