Python: QuerySolution: implements equality

pull/435/head
Tpt 2 years ago committed by Thomas Tanon
parent bdb803dab5
commit 0f43ef19e3
  1. 16
      python/src/sparql.rs

@ -3,7 +3,11 @@ use crate::map_storage_error;
use crate::model::*;
use oxigraph::model::Term;
use oxigraph::sparql::*;
use pyo3::exceptions::{PyRuntimeError, PySyntaxError, PyTypeError, PyValueError};
use pyo3::basic::CompareOp;
use pyo3::exceptions::{
PyNotImplementedError, PyRuntimeError, PySyntaxError, PyTypeError, PyValueError,
};
use pyo3::prelude::*;
use std::vec::IntoIter;
@ -104,6 +108,16 @@ impl PyQuerySolution {
buffer
}
fn __richcmp__(&self, other: &Self, op: CompareOp) -> PyResult<bool> {
match op {
CompareOp::Eq => Ok(self.inner == other.inner),
CompareOp::Ne => Ok(self.inner != other.inner),
_ => Err(PyNotImplementedError::new_err(
"Ordering is not implemented",
)),
}
}
fn __len__(&self) -> usize {
self.inner.len()
}

Loading…
Cancel
Save