fix(MySQL): MySQL UUID binding temporary string #3587

This commit is contained in:
Alex Fabijanic 2022-05-05 17:41:52 -05:00
parent 132f4f4767
commit 02dcc550b4
3 changed files with 21 additions and 2 deletions

View File

@ -213,8 +213,7 @@ void Binder::bind(std::size_t pos, const Time& val, Direction dir)
void Binder::bind(std::size_t pos, const UUID& val, Direction dir)
{
std::string str = val.toString();
bind(pos, str, dir);
bind(pos, toString(val), dir);
}

View File

@ -356,6 +356,13 @@ public:
static bool isInBound(Direction dir);
/// Returns true if direction is in bound;
protected:
const std::string& toString(const UUID& uuid);
private:
using StringList = std::vector<std::string*>;
std::unique_ptr<StringList> _pStrings;
};

View File

@ -33,6 +33,19 @@ AbstractBinder::AbstractBinder()
AbstractBinder::~AbstractBinder()
{
if (_pStrings)
{
for (auto& s : *_pStrings)
delete s;
}
}
const std::string& AbstractBinder::toString(const UUID& uuid)
{
if (!_pStrings) _pStrings.reset(new StringList);
_pStrings->push_back(new std::string(uuid.toString()));
return *_pStrings->back();
}