diff --git a/hikyuu/utilities/db_connect/DBUpgrade.cpp b/hikyuu/utilities/db_connect/DBUpgrade.cpp index cf0211d..8f3e247 100644 --- a/hikyuu/utilities/db_connect/DBUpgrade.cpp +++ b/hikyuu/utilities/db_connect/DBUpgrade.cpp @@ -25,25 +25,15 @@ namespace hku { #if HKU_ENABLE_SQLITE static bool isSQLite(DBConnectBase *db) { - try { - SQLiteConnect *sqlite = dynamic_cast(db); - return true; - } catch (...) { - // do nothing - } - return false; + SQLiteConnect *sqlite = dynamic_cast(db); + return sqlite != nullptr; } #endif #if HKU_ENABLE_MYSQL static bool isMySQL(DBConnectBase *db) { - try { - MySQLConnect *mysql = dynamic_cast(db); - return true; - } catch (...) { - // do nothing - } - return false; + MySQLConnect *mysql = dynamic_cast(db); + return mysql != nullptr; } #endif diff --git a/hikyuu/utilities/db_connect/mysql/MySQLConnect.cpp b/hikyuu/utilities/db_connect/mysql/MySQLConnect.cpp index e64ad5d..c0c646d 100755 --- a/hikyuu/utilities/db_connect/mysql/MySQLConnect.cpp +++ b/hikyuu/utilities/db_connect/mysql/MySQLConnect.cpp @@ -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); diff --git a/release.md b/release.md index 928131e..f5befd1 100644 --- a/release.md +++ b/release.md @@ -2,6 +2,7 @@ ## 1.1.0 - +fixed DBUpgrade 判断 sqlite 还是 mysql 示例 ## 1.0.9 - 2024年10月20日