Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 Prepared statements send the wrong types as parameters to the server #341

Closed
Nicoretti opened this issue May 22, 2023 · 1 comment · Fixed by #354
Closed

🐞 Prepared statements send the wrong types as parameters to the server #341

Nicoretti opened this issue May 22, 2023 · 1 comment · Fixed by #354
Assignees
Labels
bug Unwanted / harmful behavior

Comments

@Nicoretti
Copy link
Member

Nicoretti commented May 22, 2023

Summary

Prepared statements using the websocket based dialect seem to not send the correct types required/expected by the server.

Reproducing the Issue

Reproducible: always

  1. Remove the @ISSUE341 marker from the tests in test/sqlalchemy/test_suite.py

  2. Run the SQLA compliance test suit with the websocket based dialect as target
    pytest --log-debug=DEBUG --dropfirst --db exasol-websocket test/integration/sqlalchemy

  3. Have a look at the following tests

  • test/integration/sqlalchemy/test_suite.py::CastTypeDecoratorTest_exasol+exasol_driver_websocket_dbapi2::test_special_type - sqlalchemy.exc.DBAPIError: (exasol.driver.websocket._errors.Error)
  • test/integration/sqlalchemy/test_suite.py::ExistsTest_exasol+exasol_driver_websocket_dbapi2::test_select_exists - sqlalchemy.exc.DBAPIError: (exasol.driver.websocket._errors.Error)
  • test/integration/sqlalchemy/test_suite.py::ExistsTest_exasol+exasol_driver_websocket_dbapi2::test_select_exists_false - sqlalchemy.exc.DBAPIError: (exasol.driver.websocket._errors.Error)
  • test/integration/sqlalchemy/test_suite.py::InsertBehaviorTest_exasol+exasol_driver_websocket_dbapi2::test_insert_from_select - sqlalchemy.exc.DBAPIError: (exasol.driver.websocket._errors.Error)
  • test/integration/sqlalchemy/test_suite.py::InsertBehaviorTest_exasol+exasol_driver_websocket_dbapi2::test_insert_from_select_with_defaults - sqlalchemy.exc.DBAPIError: (exasol.driver.websocket._errors.Error)
  • test/integration/sqlalchemy/test_suite.py::NumericTest_exasol+exasol_driver_websocket_dbapi2::test_float_as_decimal - sqlalchemy.exc.DBAPIError: (exasol.driver.websocket._errors.Error)
  • test/integration/sqlalchemy/test_suite.py::NumericTest_exasol+exasol_driver_websocket_dbapi2::test_float_as_float - sqlalchemy.exc.DBAPIError: (exasol.driver.websocket._errors.Error)
  • test/integration/sqlalchemy/test_suite.py::NumericTest_exasol+exasol_driver_websocket_dbapi2::test_float_custom_scale - sqlalchemy.exc.DBAPIError: (exasol.driver.websocket._errors.Error)

Expected Behaviour

Statements (test cases) get executed successfully.

Actual Behaviour

Statements (test cases) fail due to invalid types for the parameters are sent to the server.

e.g.:

getString: JSON value is not a string. (Session: 1766587743101452288)

Root Cause

Not a 100% identified yet

Context

This is a snippet of the client/server conversation for test case

  • test/integration/sqlalchemy/test_suite.py::CastTypeDecoratorTest_exasol+exasol_driver_websocket_dbapi2::test_special_type - sqlalchemy.exc.DBAPIError: (exasol.driver.websocket._errors.Error)
...

127.0.0.1:57568 -> 127.0.0.1:8888
{"command": "execute", "sqlText": "CREATE TABLE t (\n\tx VARCHAR(50)\n)"}

127.0.0.1:8888 -> 127.0.0.1:57568
{"status":"ok","responseData":{"results":[{"resultType":"rowCount","rowCount":0}],"numResults":1}}

127.0.0.1:57568 -> 127.0.0.1:8888
{"command": "createPreparedStatement", "sqlText": "INSERT INTO t (x) VALUES (CAST(? AS VARCHAR(50)))"}

127.0.0.1:8888 -> 127.0.0.1:57568
{"status":"ok","responseData":{"statementHandle":7,"parameterData":{"numColumns":1,"columns":[{"name":"","dataType":{"type":"VARCHAR","size":2000000,"characterSet":"UTF8"}}]},"results":[{"resultType":"rowCount","rowCount":0}],

127.0.0.1:57568 -> 127.0.0.1:8888
{"command": "executePreparedStatement", "statementHandle": 7, "numColumns": 1, "numRows": 3, "columns": [{"name": "", "dataType": {"type": "VARCHAR", "size": 2000000, "characterSet": "UTF8"}}], "data": [[1, 2, 3]]}

127.0.0.1:8888 -> 127.0.0.1:57568
{"status":"error","exception":{"text":"getString: JSON value is not a string. (Session: 1765399198642536448)","sqlCode":"00000"}}

127.0.0.1:57568 -> 127.0.0.1:8888
{"command": "closePreparedStatement", "statementHandle": 7}

127.0.0.1:8888 -> 127.0.0.1:57568
{"status":"ok"}

...

Related Issues (optional)

@Nicoretti
Copy link
Member Author

consider exposing/adding the debug feature of pyexasol, see here.

Nicoretti added a commit that referenced this issue May 24, 2023
* Add hooks for websocket based exasol dialect
* Add support for enabling and disabling certificate validation
* Add hooks for type conversions between pyexasol and dbapi2 cursor
* Add websocket dialect/connector to ci/cd matrix
* Update dependencies
* Update README.md
* Rework dbapi2 types
* Restructure the dbapi2 module of the websocket driver
* Disable remaining failing SQLA compliance tests
   - #341
   - #342

---
Co-authored-by: Christoph Pirkl <christoph.pirkl@exasol.com>
Co-authored-by: Sebastian Bär <redcatbear@ursus-minor.de>
Co-authored-by: Torsten Kilias <tkilias@users.noreply.github.com>
Nicoretti added a commit that referenced this issue Jun 22, 2023
@Nicoretti Nicoretti self-assigned this Jun 22, 2023
Nicoretti added a commit that referenced this issue Jun 28, 2023
…the server (#354)

* Re-enable test for GitHub issue #341
* Fix failing tests from GitHub Issue-341
* Update lock file

---------
Co-authored-by: Torsten Kilias <tkilias@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unwanted / harmful behavior
Projects
None yet
1 participant