Fix typo: Rename PGEscapse to PGEscape
This commit is contained in:
@@ -164,9 +164,9 @@ fn get_missing_from_db(client: &mut Client, missing_sgs: &[i64]) -> BTreeMap<i64
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Helper function that escapes the wrapped text when writing SQL
|
/// Helper function that escapes the wrapped text when writing SQL
|
||||||
pub struct PGEscapse<'a>(pub &'a str);
|
pub struct PGEscape<'a>(pub &'a str);
|
||||||
|
|
||||||
impl<'a> fmt::Display for PGEscapse<'a> {
|
impl<'a> fmt::Display for PGEscape<'a> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let mut delim = Cow::from("$$");
|
let mut delim = Cow::from("$$");
|
||||||
while self.0.contains(&delim as &str) {
|
while self.0.contains(&delim as &str) {
|
||||||
@@ -181,12 +181,12 @@ impl<'a> fmt::Display for PGEscapse<'a> {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_pg_escape() {
|
fn test_pg_escape() {
|
||||||
let s = format!("{}", PGEscapse("test"));
|
let s = format!("{}", PGEscape("test"));
|
||||||
assert_eq!(s, "$$test$$");
|
assert_eq!(s, "$$test$$");
|
||||||
|
|
||||||
let dodgy_string = "test$$ing";
|
let dodgy_string = "test$$ing";
|
||||||
|
|
||||||
let s = format!("{}", PGEscapse(dodgy_string));
|
let s = format!("{}", PGEscape(dodgy_string));
|
||||||
|
|
||||||
// prefix and suffixes should match
|
// prefix and suffixes should match
|
||||||
let start_pos = s.find(dodgy_string).expect("expected to find dodgy string");
|
let start_pos = s.find(dodgy_string).expect("expected to find dodgy string");
|
||||||
|
|||||||
10
src/main.rs
10
src/main.rs
@@ -23,7 +23,7 @@ mod database;
|
|||||||
static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc;
|
static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc;
|
||||||
|
|
||||||
use compressor::Compressor;
|
use compressor::Compressor;
|
||||||
use database::PGEscapse;
|
use database::PGEscape;
|
||||||
|
|
||||||
use clap::{
|
use clap::{
|
||||||
crate_authors, crate_description, crate_name, crate_version, value_t_or_exit, App, Arg,
|
crate_authors, crate_description, crate_name, crate_version, value_t_or_exit, App, Arg,
|
||||||
@@ -269,10 +269,10 @@ fn main() {
|
|||||||
output,
|
output,
|
||||||
"({}, {}, {}, {}, {})",
|
"({}, {}, {}, {}, {})",
|
||||||
sg,
|
sg,
|
||||||
PGEscapse(room_id),
|
PGEscape(room_id),
|
||||||
PGEscapse(t),
|
PGEscape(t),
|
||||||
PGEscapse(s),
|
PGEscape(s),
|
||||||
PGEscapse(e)
|
PGEscape(e)
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user