forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
[Refactor] Remove reference of Configuration in odbc_connection.cc
#105
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,22 +54,6 @@ namespace { | |
| // built statically. | ||
| const boost::xpressive::sregex CONNECTION_STR_REGEX( | ||
| boost::xpressive::sregex::compile("([^=;]+)=({.+}|[^;]+|[^;])")); | ||
|
|
||
| // Load properties from the given DSN. The properties loaded do _not_ overwrite existing | ||
| // entries in the properties. | ||
| void loadPropertiesFromDSN(const std::string& dsn, | ||
| Connection::ConnPropertyMap& properties) { | ||
| driver::flight_sql::config::Configuration config; | ||
| config.LoadDsn(dsn); | ||
| Connection::ConnPropertyMap dsnProperties = config.GetProperties(); | ||
| for (auto& [key, value] : dsnProperties) { | ||
| auto propIter = properties.find(key); | ||
| if (propIter == properties.end()) { | ||
| properties.emplace(std::make_pair(std::move(key), std::move(value))); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| // Public | ||
|
|
@@ -696,46 +680,64 @@ void ODBCConnection::dropDescriptor(ODBCDescriptor* desc) { | |
|
|
||
| // Public Static | ||
| // =================================================================================== | ||
| std::string ODBCConnection::getPropertiesFromConnString( | ||
| const std::string& connStr, Connection::ConnPropertyMap& properties) { | ||
| std::string ODBCConnection::getDsnIfExists(const std::string& connStr) { | ||
| const int groups[] = {1, 2}; // CONNECTION_STR_REGEX has two groups. key: 1, value: 2 | ||
| boost::xpressive::sregex_token_iterator regexIter(connStr.begin(), connStr.end(), | ||
| CONNECTION_STR_REGEX, groups), | ||
| boost::xpressive::sregex_token_iterator regex_iter(connStr.begin(), connStr.end(), | ||
| CONNECTION_STR_REGEX, groups), | ||
| end; | ||
|
|
||
| bool isDsnFirst = false; | ||
| bool isDriverFirst = false; | ||
| std::string dsn; | ||
| for (auto it = regexIter; end != regexIter; ++regexIter) { | ||
| std::string key = *regexIter; | ||
| std::string value = *++regexIter; | ||
| bool dsn_first = false; | ||
| bool driver_first = false; | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed variable name to fit arrow convention; but I didn't change variables everywhere though, as updating the variables are for a different ticket |
||
| std::string dsn(""); | ||
| for (auto it = regex_iter; end != regex_iter; ++regex_iter) { | ||
| std::string key = *regex_iter; | ||
| std::string value = *++regex_iter; | ||
|
|
||
| // If the DSN shows up before driver key, load settings from the DSN. | ||
|
alinaliBQ marked this conversation as resolved.
Outdated
|
||
| // Only load values from the DSN once regardless of how many times the DSN | ||
| // key shows up. | ||
| if (boost::iequals(key, "DSN")) { | ||
|
alinaliBQ marked this conversation as resolved.
Outdated
|
||
| if (!isDriverFirst) { | ||
| if (!isDsnFirst) { | ||
| isDsnFirst = true; | ||
| loadPropertiesFromDSN(value, properties); | ||
| if (!driver_first) { | ||
| if (!dsn_first) { | ||
| dsn_first = true; | ||
| dsn.swap(value); | ||
| return dsn; | ||
| } | ||
| } | ||
| continue; | ||
| } else if (boost::iequals(key, "Driver")) { | ||
| if (!isDsnFirst) { | ||
| isDriverFirst = true; | ||
| if (!dsn_first) { | ||
| driver_first = true; | ||
| return dsn; | ||
| } | ||
| } | ||
|
|
||
| // Strip wrapping curly braces. | ||
| if (value.size() >= 2 && value[0] == '{' && value[value.size() - 1] == '}') { | ||
| value = value.substr(1, value.size() - 2); | ||
| } | ||
| } | ||
| return dsn; | ||
| } | ||
|
|
||
| void ODBCConnection::getPropertiesFromConnString( | ||
| const std::string& connStr, Connection::ConnPropertyMap& properties) { | ||
| const int groups[] = {1, 2}; // CONNECTION_STR_REGEX has two groups. key: 1, value: 2 | ||
| boost::xpressive::sregex_token_iterator regex_iter(connStr.begin(), connStr.end(), | ||
| CONNECTION_STR_REGEX, groups), | ||
| end; | ||
|
|
||
| for (auto it = regex_iter; end != regex_iter; ++regex_iter) { | ||
| std::string key = *regex_iter; | ||
| std::string value = *++regex_iter; | ||
|
|
||
| // Strip wrapping curly braces. | ||
| if (value.size() >= 2 && value[0] == '{' && value[value.size() - 1] == '}') { | ||
| value = value.substr(1, value.size() - 2); | ||
| } | ||
|
|
||
| // Overwrite the existing value. Later copies of the key take precedence, | ||
| // including over entries in the DSN. | ||
| properties[key] = std::move(value); | ||
| } | ||
| return dsn; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.