SQL语句匿名化

Signed-off-by: bjd <baijidong@huawei.com>
This commit is contained in:
bjd 2024-11-20 15:42:07 +08:00
parent cd94e76d48
commit fe6a3f5467
2 changed files with 5 additions and 5 deletions

View File

@ -481,7 +481,7 @@ std::string SqliteUtils::AnonySql(const std::string &sql)
std::string replaceSql = ReplaceMultipleSpaces(sql);
std::string sqlType;
if (replaceSql.size() > SQL_TYPE_SIZE) {
sqlType = SqliteUtils::StrToUpper(replaceSql.substr(0, 3));
sqlType = SqliteUtils::StrToUpper(replaceSql.substr(START_SIZE, SQL_TYPE_SIZE));
} else {
return replaceSql;
}

View File

@ -256,10 +256,10 @@ HWTEST_F(SqliteUtilsTest, SqliteUtils_Test_0039, TestSize.Level1)
HWTEST_F(SqliteUtilsTest, SqliteUtils_Test_0040, TestSize.Level1)
{
EXPECT_EQ(
SqliteUtils::AnonySql(
"CREATE TABLE TEST (id INT PRIMARY KEY, name TEXT, extend BLOB, code REAL, years UNLIMITED INT, ment ASSET, ments ASSETS)."),
"CREATE TABLE *EST (*d INT PRIMARY KEY, *ame TEXT, ***end BLOB, *ode REAL, **ars UNLIMITED INT, *ent ASSET, **nts ASSETS)");
EXPECT_EQ(SqliteUtils::AnonySql("CREATE TABLE TEST (id INT PRIMARY KEY, name TEXT, "
"extend BLOB, code REAL, years UNLIMITED INT, ment ASSET, ments ASSETS)."),
"CREATE TABLE *EST (*d INT PRIMARY KEY, *ame TEXT, "
"***end BLOB, *ode REAL, **ars UNLIMITED INT, *ent ASSET, **nts ASSETS)");
}
HWTEST_F(SqliteUtilsTest, SqliteUtils_Test_0041, TestSize.Level1)