Skip to content

Commit ad472d6

Browse files
committed
bug fixes
1 parent b4383b1 commit ad472d6

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

crates/openfang-memory/src/knowledge.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,14 @@ impl KnowledgeStore {
100100
let mut idx = 1;
101101

102102
if let Some(ref source) = pattern.source {
103-
sql.push_str(&format!(" AND (s.id = ?{idx} OR s.name = ?{idx})"));
103+
sql.push_str(&format!(
104+
" AND (s.id = ?{} OR s.name = ?{})",
105+
idx,
106+
idx + 1
107+
));
104108
params.push(Box::new(source.clone()));
105-
idx += 1;
109+
params.push(Box::new(source.clone()));
110+
idx += 2;
106111
}
107112
if let Some(ref relation) = pattern.relation {
108113
let rel_str = serde_json::to_string(relation)
@@ -112,10 +117,16 @@ impl KnowledgeStore {
112117
idx += 1;
113118
}
114119
if let Some(ref target) = pattern.target {
115-
sql.push_str(&format!(" AND (t.id = ?{idx} OR t.name = ?{idx})"));
120+
sql.push_str(&format!(
121+
" AND (t.id = ?{} OR t.name = ?{})",
122+
idx,
123+
idx + 1
124+
));
125+
params.push(Box::new(target.clone()));
116126
params.push(Box::new(target.clone()));
117-
let _ = idx;
127+
idx += 2;
118128
}
129+
let _ = idx;
119130

120131
sql.push_str(" LIMIT 100");
121132

0 commit comments

Comments
 (0)