From f912771ae6721275c6db4c269411c07c3653d335 Mon Sep 17 00:00:00 2001 From: amuldotexe Date: Fri, 20 Dec 2024 20:32:03 +0530 Subject: [PATCH 1/2] gracefully handling errors for issue https://github.com/tursodatabase/limbo/issues/494 , changes made 5 places where todo macros were replaced with relevant errors --- bindings/python/src/lib.rs | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/bindings/python/src/lib.rs b/bindings/python/src/lib.rs index aca225304..b3b618dd3 100644 --- a/bindings/python/src/lib.rs +++ b/bindings/python/src/lib.rs @@ -104,7 +104,9 @@ impl Cursor { // TODO: use stmt_is_dml to set rowcount if stmt_is_dml { - todo!() + return Err(PyErr::new::( + "DML statements (INSERT/UPDATE/DELETE) are not fully supported in this version" + ).into()); } Ok(Cursor { @@ -181,18 +183,24 @@ impl Cursor { } } - pub fn close(&self) -> Result<()> { - todo!() + pub fn close(&self) -> PyResult<()> { + Err(PyErr::new::( + "close() is not supported in this version" + )) } #[pyo3(signature = (sql, parameters=None))] - pub fn executemany(&self, sql: &str, parameters: Option>) { - todo!() + pub fn executemany(&self, sql: &str, parameters: Option>) -> PyResult<()> { + Err(PyErr::new::( + "executemany() is not supported in this version" + )) } #[pyo3(signature = (size=None))] - pub fn fetchmany(&self, size: Option) { - todo!() + pub fn fetchmany(&self, size: Option) -> PyResult>> { + Err(PyErr::new::( + "fetchmany() is not supported in this version" + )) } } @@ -228,12 +236,16 @@ impl Connection { drop(self.conn.clone()); } - pub fn commit(&self) { - todo!() + pub fn commit(&self) -> PyResult<()> { + Err(PyErr::new::( + "Transactions are not supported in this version" + )) } - pub fn rollback(&self) { - todo!() + pub fn rollback(&self) -> PyResult<()> { + Err(PyErr::new::( + "Transactions are not supported in this version" + )) } } From b7b22f303f4a68aa85b6507d86eaf4f807c99dec Mon Sep 17 00:00:00 2001 From: amuldotexe Date: Fri, 20 Dec 2024 20:36:35 +0530 Subject: [PATCH 2/2] ran cargofmt --- bindings/python/src/lib.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bindings/python/src/lib.rs b/bindings/python/src/lib.rs index b3b618dd3..595400a21 100644 --- a/bindings/python/src/lib.rs +++ b/bindings/python/src/lib.rs @@ -105,8 +105,9 @@ impl Cursor { // TODO: use stmt_is_dml to set rowcount if stmt_is_dml { return Err(PyErr::new::( - "DML statements (INSERT/UPDATE/DELETE) are not fully supported in this version" - ).into()); + "DML statements (INSERT/UPDATE/DELETE) are not fully supported in this version", + ) + .into()); } Ok(Cursor { @@ -185,21 +186,21 @@ impl Cursor { pub fn close(&self) -> PyResult<()> { Err(PyErr::new::( - "close() is not supported in this version" + "close() is not supported in this version", )) } #[pyo3(signature = (sql, parameters=None))] pub fn executemany(&self, sql: &str, parameters: Option>) -> PyResult<()> { Err(PyErr::new::( - "executemany() is not supported in this version" + "executemany() is not supported in this version", )) } #[pyo3(signature = (size=None))] pub fn fetchmany(&self, size: Option) -> PyResult>> { Err(PyErr::new::( - "fetchmany() is not supported in this version" + "fetchmany() is not supported in this version", )) } } @@ -238,13 +239,13 @@ impl Connection { pub fn commit(&self) -> PyResult<()> { Err(PyErr::new::( - "Transactions are not supported in this version" + "Transactions are not supported in this version", )) } pub fn rollback(&self) -> PyResult<()> { Err(PyErr::new::( - "Transactions are not supported in this version" + "Transactions are not supported in this version", )) } }