Skip to content

Commit

Permalink
fixed DBUpgrade 判断 sqlite 还是 mysql 示例
Browse files Browse the repository at this point in the history
  • Loading branch information
fasiondog committed Oct 21, 2024
1 parent fcee71b commit 9459115
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
18 changes: 4 additions & 14 deletions hikyuu/utilities/db_connect/DBUpgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,15 @@ namespace hku {

#if HKU_ENABLE_SQLITE
static bool isSQLite(DBConnectBase *db) {
try {
SQLiteConnect *sqlite = dynamic_cast<SQLiteConnect *>(db);
return true;
} catch (...) {
// do nothing
}
return false;
SQLiteConnect *sqlite = dynamic_cast<SQLiteConnect *>(db);
return sqlite != nullptr;
}
#endif

#if HKU_ENABLE_MYSQL
static bool isMySQL(DBConnectBase *db) {
try {
MySQLConnect *mysql = dynamic_cast<MySQLConnect *>(db);
return true;
} catch (...) {
// do nothing
}
return false;
MySQLConnect *mysql = dynamic_cast<MySQLConnect *>(db);
return mysql != nullptr;
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions hikyuu/utilities/db_connect/mysql/MySQLConnect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ int64_t MySQLConnect::exec(const std::string& sql_string) {
if (ping()) {
ret = mysql_query(m_mysql, sql_string.c_str());
} else {
SQL_THROW(ret, "SQL error{}! error msg: {}", sql_string, mysql_error(m_mysql));
SQL_THROW(ret, "SQL error: {}! error msg: {}", sql_string, mysql_error(m_mysql));
}
}

if (ret) {
SQL_THROW(ret, "SQL error{}! error msg: {}", sql_string, mysql_error(m_mysql));
SQL_THROW(ret, "SQL error: {}! error msg: {}", sql_string, mysql_error(m_mysql));
}

int64_t affect_rows = mysql_affected_rows(m_mysql);
Expand Down
1 change: 1 addition & 0 deletions release.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.1.0 -

fixed DBUpgrade 判断 sqlite 还是 mysql 示例

## 1.0.9 - 2024年10月20日

Expand Down

0 comments on commit 9459115

Please sign in to comment.