Skip to main content

escape_sql_path

Function escape_sql_path 

Source
pub fn escape_sql_path(path: &str) -> String
Expand description

Escapes a database file path for safe use in SQL statements.

This function wraps the path in double quotes and escapes internal quotes, just like escape_name(), but without the 63-character PostgreSQL identifier length limit. Use this for CREATE DATABASE, ATTACH DATABASE, COPY DATABASE, and similar statements where the argument is a file path rather than an SQL identifier.

ยงExample

use hyperdb_api::escape_sql_path;

let simple = escape_sql_path("/tmp/data.hyper");
assert_eq!(simple, "\"/tmp/data.hyper\"");

let special = escape_sql_path("/tmp/my \"db\".hyper");
assert_eq!(special, "\"/tmp/my \"\"db\"\".hyper\"");