Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Sep 21, 2024
1 parent ba046ac commit ff84801
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,16 @@ impl SqlBuilder {
}
}

pub(crate) fn append(&mut self, part: &str) {
pub(crate) fn append(&mut self, suffix: &str) {
let Self::InProgress(parts) = self else {
return;
};

parts.push(Part::Text(part.to_string()));
if let Some(Part::Text(text)) = parts.last_mut() {
text.push_str(suffix);
} else {
parts.push(Part::Text(suffix.to_string()));
}
}

pub(crate) fn finish(mut self) -> Result<String> {
Expand Down Expand Up @@ -188,6 +192,15 @@ mod tests {
);
}

#[test]
fn question_escape() {
let sql = SqlBuilder::new("SELECT 1 FROM test WHERE a IN 'a??b'");
assert_eq!(
sql.finish().unwrap(),
r"SELECT 1 FROM test WHERE a IN 'a?b'"
);
}

#[test]
fn option_as_null() {
let mut sql = SqlBuilder::new("SELECT 1 FROM test WHERE a = ?");
Expand Down

0 comments on commit ff84801

Please sign in to comment.