in squangle/mysql_client/Query.cpp [350:393]
void Query::appendValue(
folly::fbstring* s,
size_t offset,
char type,
const QueryArgument& d,
MYSQL* connection) const {
auto querySp = query_text_.getQuery();
if (d.isString()) {
if (type != 's' && type != 'v' && type != 'm') {
formatStringParseError(querySp, offset, type, "string");
}
auto value = d.asString();
s->reserve(s->size() + value.size() + 4);
s->push_back('"');
appendEscapedString(s, value, connection);
s->push_back('"');
} else if (d.isBool()) {
if (type != 'v' && type != 'm') {
formatStringParseError(querySp, offset, type, "bool");
}
s->append(d.asString());
} else if (d.isInt()) {
if (type != 'd' && type != 'v' && type != 'm' && type != 'u') {
formatStringParseError(querySp, offset, type, "int");
}
if (type == 'u') {
s->append(folly::to<folly::fbstring>(static_cast<uint64_t>(d.getInt())));
} else {
s->append(d.asString());
}
} else if (d.isDouble()) {
if (type != 'f' && type != 'v' && type != 'm') {
formatStringParseError(querySp, offset, type, "double");
}
s->append(d.asString());
} else if (d.isQuery()) {
s->append(d.getQuery().render(connection));
} else if (d.isNull()) {
s->append("NULL");
} else {
formatStringParseError(querySp, offset, type, d.typeName());
}
}