8000 refactor if conditon of host and database by 12mohaned · Pull Request #30 · chapeldev/cdo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactor if conditon of host and database #30

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/mysql/MySQL.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module MySQL {
use Map;
use SysCTypes;
use MySQLNative;

use Regexp;
/*
Enum that describes the data type held by a field in MySQL.
Note: MySQL uses TINYINT(1) internally for the BOOLEAN
Expand Down Expand Up @@ -99,7 +99,7 @@ module MySQL {
var database: string;
var username: string;
var password: string;

var myRegexp = compile("[[:space:]]*");
// let's extract the relevant info from the connection string
for (i, str) in zip(0.., connectionString.split(';')) {
select i {
Expand All @@ -112,10 +112,13 @@ module MySQL {
}

// Throw errors if anything wrong: (TODO: can be improved)
if (host == '' || database == '') {
var host_match = myRegexp.match(host).matched;
var db_match = myRegexp.match(database).matched;
if (host_match || db_match){
throw new ConnectionStringFormatError();
}


this._autocommit = autocommit;
this._prev_autocommit_state = autocommit;
this._cptr_mysqlconn = mysql_init(this._cptr_mysqlconn);
Expand Down
0