Skip to content

Commit adadfe2

Browse files
committed
Generate less Parts when handling ??
1 parent c0a2825 commit adadfe2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/sql/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ impl<'parts> SqlBuilder<'parts> {
3030
let mut parts = Vec::new();
3131
let mut rest = template;
3232
while let Some(idx) = rest.find('?') {
33-
if idx != 0 {
33+
if rest[idx + 1..].starts_with('?') {
34+
parts.push(Part::Str(&rest[..idx + 1]));
35+
rest = &rest[idx + 2..];
36+
continue;
37+
} else if idx != 0 {
3438
parts.push(Part::Str(&rest[..idx]));
3539
}
40+
3641
rest = &rest[idx + 1..];
37-
if let Some(restqq) = rest.strip_prefix('?') {
38-
parts.push(Part::Str("?"));
39-
rest = restqq;
40-
} else if let Some(restfields) = rest.strip_prefix("fields") {
42+
if let Some(restfields) = rest.strip_prefix("fields") {
4143
parts.push(Part::Fields);
4244
rest = restfields;
4345
} else {

0 commit comments

Comments
 (0)