Return int from the get_count() function

This fixes the signed/unsingned comparison. It isn't a problem because
we are not returning huge numbers from "SELECT count(*)" in our tests.
HEAD
Jochen Topf 2022-01-27 13:05:06 +01:00
parent 265cf9e420
commit 63b4d6eb08
2 changed files with 3 additions and 10 deletions

View File

@ -50,11 +50,6 @@ public:
return std::stoi(result_as_string(cmd));
}
unsigned long result_as_ulong(std::string const &cmd) const
{
return std::stoul(result_as_string(cmd));
}
double result_as_double(std::string const &cmd) const
{
return std::stod(result_as_string(cmd));
@ -80,13 +75,12 @@ public:
return res;
}
unsigned long get_count(char const *table_name,
std::string const &where = "") const
int get_count(char const *table_name, std::string const &where = "") const
{
auto const query = "SELECT count(*) FROM {} {} {}"_format(
table_name, (where.empty() ? "" : "WHERE"), where);
return result_as_ulong(query);
return result_as_int(query);
}
void require_has_table(char const *table_name) const

View File

@ -214,8 +214,7 @@ public:
REQUIRE_NOTHROW(db.run_import(opt, opl.c_str()));
}
unsigned long obj_count(testing::pg::conn_t const &conn, osmid_t id,
char const *cls)
int obj_count(testing::pg::conn_t const &conn, osmid_t id, char const *cls)
{
char const tchar = m_opl_factory.type();
return conn.get_count("place",