phonograph/phono-backends/src/lib.rs

20 lines
796 B
Rust
Raw Normal View History

2025-08-04 13:59:42 -07:00
pub mod client;
2025-07-08 16:54:51 -07:00
pub mod pg_acl;
2025-07-08 14:37:03 -07:00
pub mod pg_attribute;
2025-07-08 16:54:51 -07:00
pub mod pg_class;
pub mod pg_database;
pub mod pg_namespace;
pub mod pg_role;
pub mod rolnames;
2025-07-18 16:20:03 -07:00
/// 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('"', "\"\""))
}