-
Notifications
You must be signed in to change notification settings - Fork 97
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
Conversation
There was a problem hiding this 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
There was a problem hiding this 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:
CodeCompass/util/src/dbutil.cpp
Lines 175 to 179 in 1097e5c
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;";
There was a problem hiding this 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
@matebelenyesi I advise do not create a pull request from the master branch of your fork, instead create a new branch. |
Characters are replaced to underscore in connection string which are not in [a-zA-Z0-9_] set.