Skip to content

Commit 9ee8ae7

Browse files
committed
feat: change to use a constant for the agent_info table name
1 parent 4f1cc31 commit 9ee8ae7

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/agent/agent_info/src/agent_info_persistance.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ bool AgentInfoPersistance::AgentInfoIsEmpty() const
5757
{
5858
try
5959
{
60-
SQLite::Statement query(*m_db, "SELECT COUNT(*) FROM agent_info;");
60+
SQLite::Statement query(*m_db, "SELECT COUNT(*) FROM " + AGENT_INFO_TABLE_NAME + ";");
6161
query.executeStep();
6262
const auto count = query.getColumn(0).getInt();
6363
return count == 0;
@@ -74,7 +74,8 @@ void AgentInfoPersistance::CreateAgentInfoTable()
7474
{
7575
try
7676
{
77-
m_db->exec("CREATE TABLE IF NOT EXISTS agent_info ("
77+
m_db->exec("CREATE TABLE IF NOT EXISTS " + AGENT_INFO_TABLE_NAME +
78+
" ("
7879
"name TEXT, "
7980
"key TEXT, "
8081
"uuid TEXT"
@@ -106,13 +107,14 @@ void AgentInfoPersistance::InsertDefaultAgentInfo()
106107
{
107108
try
108109
{
109-
SQLite::Statement query(*m_db, "SELECT COUNT(*) FROM agent_info;");
110+
SQLite::Statement query(*m_db, "SELECT COUNT(*) FROM " + AGENT_INFO_TABLE_NAME + ";");
110111
query.executeStep();
111112
const auto count = query.getColumn(0).getInt();
112113

113114
if (count == 0)
114115
{
115-
SQLite::Statement insert(*m_db, "INSERT INTO agent_info (name, key, uuid) VALUES (?, ?, ?);");
116+
SQLite::Statement insert(*m_db,
117+
"INSERT INTO " + AGENT_INFO_TABLE_NAME + " (name, key, uuid) VALUES (?, ?, ?);");
116118
insert.exec();
117119
}
118120
}
@@ -126,7 +128,7 @@ void AgentInfoPersistance::SetAgentInfoValue(const std::string& column, const st
126128
{
127129
try
128130
{
129-
SQLite::Statement query(*m_db, "UPDATE agent_info SET " + column + " = ?;");
131+
SQLite::Statement query(*m_db, "UPDATE " + AGENT_INFO_TABLE_NAME + " SET " + column + " = ?;");
130132
query.bind(1, value);
131133
query.exec();
132134
}
@@ -141,7 +143,7 @@ std::string AgentInfoPersistance::GetAgentInfoValue(const std::string& column) c
141143
std::string value;
142144
try
143145
{
144-
SQLite::Statement query(*m_db, "SELECT " + column + " FROM agent_info LIMIT 1;");
146+
SQLite::Statement query(*m_db, "SELECT " + column + " FROM " + AGENT_INFO_TABLE_NAME + " LIMIT 1;");
145147
if (query.executeStep())
146148
{
147149
value = query.getColumn(0).getText();

0 commit comments

Comments
 (0)