Skip to content

Commit

Permalink
Better escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
def- committed Nov 6, 2023
1 parent 6e9a300 commit bfb1c5a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions postgres.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ schema_pqxx::schema_pqxx(std::string &conninfo, bool no_catalog, bool dump_state
if (no_catalog && ((schema == "pg_catalog") || (schema == "mz_catalog") || (schema == "mz_internal") || (schema == "information_schema")))
continue;

tables.push_back(table(obj["name"].get<string>(),
schema,
db,
tables.push_back(table(w.quote_name(obj["name"].get<string>()),
w.quote_name(schema),
w.quote_name(db),
((obj["table_type"].get<string>() == "BASE TABLE") ? true : false)));
}
} else {
Expand Down Expand Up @@ -229,9 +229,9 @@ schema_pqxx::schema_pqxx(std::string &conninfo, bool no_catalog, bool dump_state
if (no_catalog && ((schema == "pg_catalog") || (schema == "mz_catalog") || (schema == "mz_internal") || (schema == "information_schema")))
continue;

tables.push_back(table(name,
schema,
db,
tables.push_back(table(w.quote_name(name),
w.quote_name(schema),
w.quote_name(db),
((table_type == "BASE TABLE") ? true : false)));

if (dump_state) {
Expand Down Expand Up @@ -279,12 +279,12 @@ schema_pqxx::schema_pqxx(std::string &conninfo, bool no_catalog, bool dump_state

r = w.exec(q);
for (auto row : r) {
column c(row[0].as<string>(), oid2type[row[1].as<OID>()]);
column c(w.quote_name(row[0].as<string>()), oid2type[row[1].as<OID>()]);
t->columns().push_back(c);

if (dump_state) {
json obj;
obj["name"] = row[0].as<string>();
obj["name"] = w.quote_name(row[0].as<string>());
obj["type"] = row[1].as<OID>();
data["tables"][table_index]["columns"].push_back(obj);
}
Expand Down
2 changes: 1 addition & 1 deletion relmodel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct table : named_relation {
schema(schema),
db(db),
is_base_table(base_table) { }
virtual string ident() { return db.empty() ? ("\"" + schema + "\".\"" + name + "\"") : ("\"" + db + "\".\"" + schema + "\".\"" + name + "\""); }
virtual string ident() { return db.empty() ? (schema + "." + name) : (db + "." + schema + "." + name); }
virtual ~table() { };
};

Expand Down

0 comments on commit bfb1c5a

Please sign in to comment.