ansible-mssql-query icon indicating copy to clipboard operation
ansible-mssql-query copied to clipboard

Value of unknown type: <class 'decimal.Decimal'

Open nicolaibaralmueller opened this issue 4 years ago • 2 comments

Using below query fails.

      - name: query
        mssql_query:
          login_user: sa
          login_password: "{{ sql_admin_password }}"
          login_host: localhost
          db: msdb
          #as_dict: true
          query: >
                SELECT bcks.database_name, bckS.backup_start_date, bckS.backup_finish_date, CAST(bcks.backup_size / 1073741824.0E AS DECIMAL(10, 2)) as [Backup Size(GB)],
                is_compressed, is_encrypted, physical_device_name
                FROM  msdb.dbo.backupset bckS INNER JOIN msdb.dbo.backupmediaset bckMS
                ON bckS.media_set_id = bckMS.media_set_id
                INNER JOIN msdb.dbo.backupmediafamily bckMF
                ON bckMS.media_set_id = bckMF.media_set_id
                WHERE bckS.backup_finish_date > (SELECT CONVERT(varchar, getdate(), 23))
                ORDER BY bckS.backup_start_date DESC
        register: backupset
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: Value of unknown type: <class 'decimal.Decimal'>, 730.48
fatal: [xx.xx.xx.xx]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 102, in <module>\n  File \"<stdin>\", line 94, in _ansiballz_main\n  File \"<stdin>\", line 40, in invoke_module\n  File \"/usr/lib/python2.7/runpy.py\", line 188, in run_module\n    fname, loader, pkg_name)\n  File \"/usr/lib/python2.7/runpy.py\", line 82, in _run_module_code\n    mod_name, mod_fname, mod_loader, pkg_name)\n  File \"/usr/lib/python2.7/runpy.py\", line 72, in _run_code\n    exec code in run_globals\n  File \"/tmp/ansible_mssql_query_payload_CE9v8f/ansible_mssql_query_payload.zip/ansible/modules/mssql_query.py\", line 168, in <module>\n  File \"/tmp/ansible_mssql_query_payload_CE9v8f/ansible_mssql_query_payload.zip/ansible/modules/mssql_query.py\", line 164, in main\n  File \"/tmp/ansible_mssql_query_payload_CE9v8f/ansible_mssql_query_payload.zip/ansible/module_utils/basic.py\", line 2072, in exit_json\n  File \"/tmp/ansible_mssql_query_payload_CE9v8f/ansible_mssql_query_payload.zip/ansible/module_utils/basic.py\", line 2065, in _return_formatted\n  File \"/tmp/ansible_mssql_query_payload_CE9v8f/ansible_mssql_query_payload.zip/ansible/module_utils/basic.py\", line 422, in remove_values\n  File \"/tmp/ansible_mssql_query_payload_CE9v8f/ansible_mssql_query_payload.zip/ansible/module_utils/basic.py\", line 401, in _remove_values_conditions\nTypeError: Value of unknown type: <class 'decimal.Decimal'>, 730.48\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

Executing the query manually produces no error. Seems that the module does not support decimal datatypes in the output.

nicolaibaralmueller avatar May 26 '20 07:05 nicolaibaralmueller