Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wh002 committed Mar 15, 2023
1 parent a47ac31 commit 3fd2369
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/runtime/ranger/ranger_resource_policy_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,11 @@ std::string get_database_name_from_app_name(const std::string &app_name)

std::string get_table_name_from_app_name(const std::string &app_name)
{
return app_name.substr(get_database_name_from_app_name(app_name).size());
std::string database_name = get_database_name_from_app_name(app_name);
if (database_name.empty()) {
return app_name;
}
return app_name.substr(database_name.size() + 1);
}
} // namespace ranger
} // namespace dsn
6 changes: 3 additions & 3 deletions src/runtime/test/ranger_resource_policy_manager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ TEST(ranger_resource_policy_manager_test, get_table_name_from_app_name_test)
std::string app_name;
std::string expected_result;
} tests[] = {{"", ""},
{".", ""},
{"...", ".."},
{".", "."},
{"...", "..."},
{"database_name.", ""},
{".table_name", "table_name"},
{".table_name", ".table_name"},
{"app_name", "app_name"},
{"database_name.table_name", "table_name"},
{"a.b.c", "b.c"}};
Expand Down

0 comments on commit 3fd2369

Please sign in to comment.