fix query builder

This commit is contained in:
chatlanin 2024-07-24 11:22:39 +03:00
parent 53b5ccc9d8
commit 8f3418e03d
2 changed files with 9 additions and 9 deletions

View File

@ -13,19 +13,19 @@ namespace pgxx::builder
std::string make_one(First f)
{
f = std::regex_replace(f, std::regex("'"), "[quote]");
return std::string("'") + f + std::string("',");
return hack::string::str_concat + "'" + f + "',";
}
inline std::string make_one(const char* f)
{
auto f_str = std::string(f);
f_str = std::regex_replace(f_str, std::regex("'"), "[quote]");
return std::string("'") + f_str + std::string("',");
return hack::string::str_concat + "'" + f_str + "',";
}
inline std::string make_one(char f)
{
return std::string("'") + f + std::string("',");
return std::string("'") + f + "',";
}
template<typename First>
@ -34,28 +34,28 @@ namespace pgxx::builder
{
auto f_str = std::to_string(f);
f_str = std::regex_replace(f_str, std::regex("'"), "[quote]");
return std::string("'") + f_str + std::string("',");
return hack::string::str_concat + "'" + f_str + "',";
}
inline std::string make_one(const float f)
{
auto f_str = std::to_string(f);
f_str = std::regex_replace(f_str, std::regex("'"), "[quote]");
return f_str + std::string(",");
return hack::string::str_concat + f_str + ",";
}
inline std::string make_one(int f)
{
auto f_str = std::to_string(f);
f_str = std::regex_replace(f_str, std::regex("'"), "[quote]");
return f_str + std::string(",");
return hack::string::str_concat + f_str + ",";
}
inline std::string make_one(const std::string& f)
{
auto f_str = f;
f_str = std::regex_replace(f_str, std::regex("'"), "[quote]");
return hack::string::str_concat + "'" + f_str + "'::jsonb,";
return hack::string::str_concat + f_str + ",";
}
inline std::string make_one(const JSON& f)

View File

@ -27,7 +27,7 @@ auto main(int argc, char* args[]) -> int
}
};
for (auto i = 0; i < 1'000; ++i)
for (auto i = 0; i < 10; ++i)
{
std::thread th([&j](){
auto r = PGXX().execute("con_1", "read_and_write", j);
@ -35,7 +35,7 @@ auto main(int argc, char* args[]) -> int
th.detach();
}
for (auto i = 0; i < 1'000; ++i)
for (auto i = 0; i < 10; ++i)
{
auto r = PGXX().execute("con_2", "read_and_write", j);
}