Skip to content

Commit 519183d

Browse files
committed
Use raw string literals in several places to avoid quoting
1 parent 3e44438 commit 519183d

5 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/db-copy-mgr.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,10 @@ class db_copy_mgr_t
333333
for (char const *c = s; *c; ++c) {
334334
switch (*c) {
335335
case '"':
336-
m_current->buffer += "\\\\\"";
336+
m_current->buffer += R"(\\")";
337337
break;
338338
case '\\':
339-
m_current->buffer += "\\\\\\\\";
339+
m_current->buffer += R"(\\\\)";
340340
break;
341341
case '\n':
342342
m_current->buffer += "\\n";

src/flex-table-column.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,5 +183,5 @@ std::string flex_table_column_t::sql_modifiers() const
183183

184184
std::string flex_table_column_t::sql_create() const
185185
{
186-
return "\"{}\" {} {},"_format(m_name, sql_type_name(), sql_modifiers());
186+
return R"("{}" {} {},)"_format(m_name, sql_type_name(), sql_modifiers());
187187
}

src/flex-table.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ void table_connection_t::stop(bool updateable, bool append)
247247
m_db_connection->exec(sql);
248248

249249
m_db_connection->exec("DROP TABLE {}"_format(table().full_name()));
250-
m_db_connection->exec("ALTER TABLE {} RENAME TO \"{}\""_format(
250+
m_db_connection->exec(R"(ALTER TABLE {} RENAME TO "{}")"_format(
251251
table().full_tmp_name(), table().name()));
252252
m_id_index_created = false;
253253

@@ -263,7 +263,7 @@ void table_connection_t::stop(bool updateable, bool append)
263263

264264
// Use fillfactor 100 for un-updateable imports
265265
m_db_connection->exec(
266-
"CREATE INDEX ON {} USING GIST (\"{}\") {} {}"_format(
266+
R"(CREATE INDEX ON {} USING GIST ("{}") {} {})"_format(
267267
table().full_name(), table().geom_column().name(),
268268
(updateable ? "" : "WITH (fillfactor = 100)"),
269269
tablespace_clause(table().index_tablespace())));

src/pgsql-helper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void drop_geom_check_trigger(pg_conn_t *db_connection,
6565
{
6666
std::string func_name = qualified_name(schema, table + "_osm2pgsql_valid");
6767

68-
db_connection->exec("DROP TRIGGER \"{}\" ON {};"_format(
68+
db_connection->exec(R"(DROP TRIGGER "{}" ON {};)"_format(
6969
table + "_osm2pgsql_valid", qualified_name(schema, table)));
7070

7171
db_connection->exec("DROP FUNCTION IF EXISTS {} ();"_format(func_name));

src/table.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ void table_t::start(std::string const &conninfo, std::string const &table_space)
107107

108108
//first with the regular columns
109109
for (auto const &column : m_columns) {
110-
sql += "\"{}\" {},"_format(column.name, column.type_name);
110+
sql += R"("{}" {},)"_format(column.name, column.type_name);
111111
}
112112

113113
//then with the hstore columns
114114
for (auto const &hcolumn : m_hstore_columns) {
115-
sql += "\"{}\" hstore,"_format(hcolumn);
115+
sql += R"("{}" hstore,)"_format(hcolumn);
116116
}
117117

118118
//add tags column
@@ -225,7 +225,7 @@ void table_t::stop(bool updateable, bool enable_hstore_index,
225225
m_sql_conn->exec(sql);
226226

227227
m_sql_conn->exec("DROP TABLE {}"_format(qual_name));
228-
m_sql_conn->exec("ALTER TABLE {} RENAME TO \"{}\""_format(
228+
m_sql_conn->exec(R"(ALTER TABLE {} RENAME TO "{}")"_format(
229229
qual_tmp_name, m_target->name));
230230

231231
log_info("Creating geometry index on table '{}'...", m_target->name);
@@ -258,7 +258,7 @@ void table_t::stop(bool updateable, bool enable_hstore_index,
258258
}
259259
for (auto const &hcolumn : m_hstore_columns) {
260260
m_sql_conn->exec(
261-
"CREATE INDEX ON {} USING GIN (\"{}\") {}"_format(
261+
R"(CREATE INDEX ON {} USING GIN ("{}") {})"_format(
262262
qual_name, hcolumn,
263263
tablespace_clause(table_space_index)));
264264
}

0 commit comments

Comments
 (0)