Skip to content

Commit 65c1d7b

Browse files
committed
test
1 parent ba046ac commit 65c1d7b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/sql/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,16 @@ impl SqlBuilder {
8585
}
8686
}
8787

88-
pub(crate) fn append(&mut self, part: &str) {
88+
pub(crate) fn append(&mut self, suffix: &str) {
8989
let Self::InProgress(parts) = self else {
9090
return;
9191
};
9292

93-
parts.push(Part::Text(part.to_string()));
93+
if let Some(Part::Text(text)) = parts.last_mut() {
94+
text.push_str(suffix);
95+
} else {
96+
parts.push(Part::Text(suffix.to_string()));
97+
}
9498
}
9599

96100
pub(crate) fn finish(mut self) -> Result<String> {
@@ -188,6 +192,12 @@ mod tests {
188192
);
189193
}
190194

195+
#[test]
196+
fn question_escape() {
197+
let sql = SqlBuilder::new("SELECT 1 FROM test WHERE a IN 'a??b'");
198+
assert_eq!(sql.finish().unwrap(), r"SELECT 1 FROM test WHERE a IN 'a?b'");
199+
}
200+
191201
#[test]
192202
fn option_as_null() {
193203
let mut sql = SqlBuilder::new("SELECT 1 FROM test WHERE a = ?");

0 commit comments

Comments
 (0)