Skip to content

Commit

Permalink
More ClickHouse escape fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfellows committed Jul 26, 2024
1 parent f1847d3 commit 40766cd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Source/moja.modules.cbm/src/flatrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ namespace cbm {
firstItem = false;
if (!value.isNull()) {
std::string currentValue = value;
if (csvFormat) {
boost::replace_all(currentValue, "'", "\\'");
if (!csvFormat) {
boost::replace_all(currentValue, "'", "''");
}

valueStr += (boost::format("%1%%2%%3%") % quote % currentValue % quote).str();
Expand Down Expand Up @@ -286,12 +286,12 @@ namespace cbm {
static const std::string dbRecord = "%1%,%2%,'%3%','%4%',%5%";

auto classifierStr = FlatRecordHelper::BuildClassifierValueString(_classifierValues, csvFormat);
auto errorStr = _error;
std::string errorStr = _error;

if (csvFormat) {
boost::replace_all(errorStr, "\"", "'");
} else {
boost::replace_all(errorStr, "'", "\\'");
boost::replace_all(errorStr, "'", "''");
}

return (boost::format(csvFormat ? csvRecord : dbRecord)
Expand Down

0 comments on commit 40766cd

Please sign in to comment.