fix schema & fix tests

This commit is contained in:
qdequele 2020-01-15 18:53:49 +01:00
parent 116a637cfd
commit ae0a11e422
No known key found for this signature in database
GPG key ID: B3F0A000EBF11745
3 changed files with 22 additions and 6 deletions

View file

@ -109,6 +109,9 @@ impl Schema {
pub fn set_indexed<S: Into<String>>(&mut self, name: S) -> SResult<(FieldId, IndexedPos)> {
let id = self.fields_map.insert(name.into())?;
if let Some(indexed_pos) = self.indexed_map.get(&id) {
return Ok((id, *indexed_pos))
};
let pos = self.indexed.len() as u16;
self.indexed.push(id);
self.indexed_map.insert(id, pos.into());