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

Keyword "Connect using custom params" requires quotes (") around the connection string #173

Closed
amochin opened this issue Jun 7, 2023 · 1 comment
Assignees
Labels
Milestone

Comments

@amochin
Copy link
Collaborator

amochin commented Jun 7, 2023

The following example would work:

Connect To Database Using Custom Params    oracledb    "${con_str}"

But if you put no quotation marks around the connection string param, there is an error:

Connect To Database Using Custom Params    oracledb    ${con_str}

In order to avoid the backwards incompatibility, the code should be improved in the way that both options (with and without quotes) work.

Here is a full example for the oracle database:

*** Variables ***
${DBHost}       127.0.0.1
${DBName}       MY_DB
${DBPass}       pass
${DBPort}       1521
${DBUser}       db_user

*** Keywords ***
Connect To DB
    ${con_str} =    Catenate    SEPARATOR=${EMPTY}
    ...    ${DBUser}/${DBPass}@
    ...    ${DBHost}:${DBPort}/${DBName}
    Connect To Database Using Custom Params    oracledb    "${con_str}"
@amochin amochin added the bug label Jun 7, 2023
@amochin amochin added this to the v1.3.0 milestone Jun 7, 2023
@amochin amochin self-assigned this Jun 13, 2023
amochin added a commit that referenced this issue Jun 13, 2023
amochin added a commit that referenced this issue Jun 14, 2023
…connection strings with and without quotes"

This reverts commit 042c08f.
amochin added a commit that referenced this issue Jun 14, 2023
…on String" for connection strings. The original keyword 'Connect using custom params' handles params map strings only,
@amochin
Copy link
Collaborator Author

amochin commented Jun 14, 2023

It turns out to be not a bug, but a feature :)
The keyword "Connect To Database Using Custom Params" was not supposed to work with pure connections strings / URI's, having all connection values in one string.

Instead, it Interprets the db_connect_string parameter value as a list of named arguments, which would be passed to the "connect" function of the selected db module. Example for psycopg2:
database='my_db_test', user='postgres', password='s3cr3t', host='tiger.foobar.com', port=5432

So I left the keyword basically in the original state, just slightly improved the code and the docs.

But I've also added a new keyword Connect To Database Using Custom Connection String - it's designed to work with combined connection strings / URI's like this:
postgresql://postgres:s3cr3t@tiger.foobar.com:5432/my_db_test

@amochin amochin closed this as completed Jun 21, 2023
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