Skip to content

Commit

Permalink
Generate less Parts when handling ??
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Sep 18, 2024
1 parent c0a2825 commit 00044a2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ impl<'parts> SqlBuilder<'parts> {
let mut parts = Vec::new();
let mut rest = template;
while let Some(idx) = rest.find('?') {
if idx != 0 {
if rest[idx+1..].starts_with('?') {
parts.push(Part::Str(&rest[..idx+1]));
rest = &rest[idx + 2..];
continue
} else if idx != 0 {
parts.push(Part::Str(&rest[..idx]));
}

rest = &rest[idx + 1..];
if let Some(restqq) = rest.strip_prefix('?') {
parts.push(Part::Str("?"));
rest = restqq;
} else if let Some(restfields) = rest.strip_prefix("fields") {
if let Some(restfields) = rest.strip_prefix("fields") {
parts.push(Part::Fields);
rest = restfields;
} else {
Expand Down

0 comments on commit 00044a2

Please sign in to comment.