diff --git a/src/dataset.rs b/src/dataset.rs index c6f99df0..3ef59d24 100644 --- a/src/dataset.rs +++ b/src/dataset.rs @@ -567,7 +567,7 @@ impl Dataset { /// /// let ds = Dataset::open(Path::new("fixtures/roads.geojson")).unwrap(); /// let query = "SELECT kind, is_bridge, highway FROM roads WHERE highway = 'pedestrian'"; - /// let result_set = ds.execute_sql(query, None, sql::Dialect::DEFAULT).unwrap().unwrap(); + /// let mut result_set = ds.execute_sql(query, None, sql::Dialect::DEFAULT).unwrap().unwrap(); /// /// assert_eq!(10, result_set.feature_count()); /// diff --git a/src/vector/sql.rs b/src/vector/sql.rs index decd23d5..ef7d717d 100644 --- a/src/vector/sql.rs +++ b/src/vector/sql.rs @@ -1,4 +1,4 @@ -use std::ops::Deref; +use std::ops::{Deref, DerefMut}; use gdal_sys::GDALDatasetH; @@ -21,6 +21,12 @@ impl<'a> Deref for ResultSet<'a> { } } +impl<'a> DerefMut for ResultSet<'a> { + fn deref_mut(&mut self) -> &mut ::Target { + &mut self.layer + } +} + impl<'a> Drop for ResultSet<'a> { fn drop(&mut self) { unsafe { gdal_sys::GDALDatasetReleaseResultSet(self.dataset, self.layer.c_layer()) }; diff --git a/src/vector/vector_tests/mod.rs b/src/vector/vector_tests/mod.rs index b6845135..2231a13f 100644 --- a/src/vector/vector_tests/mod.rs +++ b/src/vector/vector_tests/mod.rs @@ -67,7 +67,7 @@ fn test_layer_spatial_ref() { #[test] fn test_layer_capabilities() { - let mut ds = Dataset::open(fixture!("roads.geojson")).unwrap(); + let ds = Dataset::open(fixture!("roads.geojson")).unwrap(); let layer = ds.layer(0).unwrap(); assert!(!layer.has_capability(OLCFastSpatialFilter)); diff --git a/src/vector/vector_tests/sql.rs b/src/vector/vector_tests/sql.rs index 82fffc51..34e0d198 100644 --- a/src/vector/vector_tests/sql.rs +++ b/src/vector/vector_tests/sql.rs @@ -10,7 +10,7 @@ use crate::{ fn test_sql() { let ds = Dataset::open(fixture!("roads.geojson")).unwrap(); let query = "SELECT kind, is_bridge, highway FROM roads WHERE highway = 'pedestrian'"; - let result_set = ds + let mut result_set = ds .execute_sql(query, None, sql::Dialect::DEFAULT) .unwrap() .unwrap(); @@ -46,7 +46,7 @@ fn test_sql_with_spatial_filter() { let query = "SELECT * FROM roads WHERE highway = 'pedestrian'"; let ds = Dataset::open(fixture!("roads.geojson")).unwrap(); let bbox = Geometry::bbox(26.1017, 44.4297, 26.1025, 44.4303).unwrap(); - let result_set = ds + let mut result_set = ds .execute_sql(query, Some(&bbox), sql::Dialect::DEFAULT) .unwrap() .unwrap(); @@ -77,7 +77,7 @@ fn test_sql_with_dialect() { let query = "SELECT * FROM roads WHERE highway = 'pedestrian' and NumPoints(GEOMETRY) = 3"; let ds = Dataset::open(fixture!("roads.geojson")).unwrap(); let bbox = Geometry::bbox(26.1017, 44.4297, 26.1025, 44.4303).unwrap(); - let result_set = ds + let mut result_set = ds .execute_sql(query, Some(&bbox), sql::Dialect::SQLITE) .unwrap() .unwrap(); @@ -99,7 +99,7 @@ fn test_sql_with_dialect() { fn test_sql_empty_result() { let ds = Dataset::open(fixture!("roads.geojson")).unwrap(); let query = "SELECT kind, is_bridge, highway FROM roads WHERE highway = 'jazz hands 👐'"; - let result_set = ds + let mut result_set = ds .execute_sql(query, None, sql::Dialect::DEFAULT) .unwrap() .unwrap();