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

change invalid connectionstring to valid #489

Merged
merged 1 commit into from
Dec 2, 2020

Conversation

matebelenyesi
Copy link
Contributor

@matebelenyesi matebelenyesi commented Nov 10, 2020

Characters are replaced to underscore in connection string which are not in [a-zA-Z0-9_] set.

@intjftw intjftw added the Status: WIP 👷 Issue or PR under development - feel free to review, though! label Nov 11, 2020
@intjftw intjftw self-requested a review November 11, 2020 12:09
Copy link
Collaborator

@intjftw intjftw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes should be put into util/src/dbutil.cpp

Copy link
Collaborator

@mcserep mcserep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have checked and ODB automatically convert identifiers to quoted identifier correctly. (@bruntib already made a remark on one of our previous meetings that there is no issue with our database table names containing uppercase letters. Only the database name raises an error.)

There is a second kind of identifier: the delimited identifier or quoted identifier. It is formed by enclosing an arbitrary sequence of characters in double-quotes ("). A delimited identifier is always an identifier, never a key word. So "select" could be used to refer to a column or table named “select”, whereas an unquoted select would be taken as a key word and would therefore provoke a parse error when used where a table or column name is expected. The example can be written with quoted identifiers like this:

UPDATE "my_table" SET "a" = 5;

The issue is with the database creation, which we perform through a native SQL script. Here, the database name is not enclosed between double-quotes:

std::string createCmd = "CREATE DATABASE " + dbName_
+ " ENCODING = 'SQL_ASCII'"
+ " LC_CTYPE='C'"
+ " LC_COLLATE='C'"
+ " TEMPLATE template0;";

Fixing it like this solves the original issue:

std::string createCmd = "CREATE DATABASE \"" + dbName_ + "\""
  + " ENCODING = 'SQL_ASCII'"
  + " LC_CTYPE='C'"
  + " LC_COLLATE='C'"
  + " TEMPLATE template0;";

@mcserep mcserep added Kind: Bug ⚠️ Target: Database Issues related to the database schema of the core or a plugin, or database handling in general. labels Nov 25, 2020
Copy link
Collaborator

@mcserep mcserep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good. The commits shall be squashed before merge.

change convert function


move connection string modifying functions to dbutil


smaller typo and formatting fixes


change connenctionstring only with pgsql 


change back everything and adding quotation marks
@mcserep
Copy link
Collaborator

mcserep commented Dec 2, 2020

@matebelenyesi I advise do not create a pull request from the master branch of your fork, instead create a new branch.
Now there will be a conflict between Ericsson's master and your master, and basically you will have to force overwrite your own master branch to get them in sync again.

@mcserep mcserep removed the Status: WIP 👷 Issue or PR under development - feel free to review, though! label May 8, 2021
@mcserep mcserep linked an issue May 8, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Kind: Bug ⚠️ Target: Database Issues related to the database schema of the core or a plugin, or database handling in general.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Database name must not contain hyphen ('-') character
3 participants