forked from 2sys/phonograph
19 lines
796 B
Rust
19 lines
796 B
Rust
pub mod client;
|
|
pub mod pg_acl;
|
|
pub mod pg_attribute;
|
|
pub mod pg_class;
|
|
pub mod pg_database;
|
|
pub mod pg_namespace;
|
|
pub mod pg_role;
|
|
pub mod rolnames;
|
|
|
|
/// Given a raw identifier (such as a table name, column name, etc.), format it
|
|
/// so that it may be safely interpolated into a SQL query.
|
|
pub fn escape_identifier(identifier: &str) -> String {
|
|
// Escaping identifiers for Postgres is fairly easy, provided that the input is
|
|
// already known to contain no invalid multi-byte sequences. Backslashes may
|
|
// remain as-is, and embedded double quotes are escaped simply by doubling
|
|
// them (`"` becomes `""`). Refer to the PQescapeInternal() function in
|
|
// libpq (fe-exec.c) and Diesel's PgQueryBuilder::push_identifier().
|
|
format!("\"{}\"", identifier.replace('"', "\"\""))
|
|
}
|