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

Query params don't work for MS SQL (pymssql) #211

Closed
amochin opened this issue Feb 28, 2024 · 1 comment
Closed

Query params don't work for MS SQL (pymssql) #211

amochin opened this issue Feb 28, 2024 · 1 comment
Assignees
Labels
Milestone

Comments

@amochin
Copy link
Collaborator

amochin commented Feb 28, 2024

This works fine with a lot of DB drivers like oracledb or psycopg2, but fails with pymssql:

*** Variables ***
@{PARAM}    Franz Allan
${QUERY}    SELECT id FROM person WHERE FIRST_NAME=%s

*** Test Cases ***
Test 1
    Query    ${QUERY}    parameters=${PARAM}

Pymssql throws an exception:

ValueError: 'params' arg (<class 'list'>) can be only a tuple or a dictionary.

This happens because the parameters are handled by the library internally as lists and some of Python DB drivers accept it, but e.g. pymssql - not.

@amochin amochin added the bug label Feb 28, 2024
@amochin amochin added this to the v1.4.3 milestone Feb 28, 2024
@amochin amochin self-assigned this Feb 28, 2024
@amochin
Copy link
Collaborator Author

amochin commented Feb 28, 2024

I'm switching internal handling of query parameters from lists to tuples.
Apparently, using tuples is actually the default and recommended way, which should be supported by most of python DB drivers.

Handling the data type internally is better than letting the user decide it, because the latter option would be too complicated. Also transferring tests and keywords between different databases would become difficult.

From the user perspective there are no changes.
The parameters in Robot Framework are still to be formed as lists - they're converted to tuples automatically when calling the keywords.

If in future we found a DB driver which accepts lists only, a special handling could be added.

amochin added a commit that referenced this issue Feb 28, 2024
Fix handling query params for MS SQL #211
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant