Skip to content

Commit

Permalink
Fix quaint geometry as raw
Browse files Browse the repository at this point in the history
  • Loading branch information
Oreilles committed Oct 3, 2024
1 parent c08999d commit c7a5ed3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions quaint/src/visitor/mssql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,10 @@ impl<'a> Visitor<'a> for Mssql<'a> {
// TODO@geometry: find a way to avoid cloning
ValueType::Geometry(g) => g
.as_ref()
.map(|g| self.visit_function(geom_from_text(g.wkt.clone(), g.srid, false))),
.map(|g| self.visit_function(geom_from_text(g.wkt.clone().raw(), g.srid.map(IntoRaw::raw), false))),
ValueType::Geography(g) => g
.as_ref()
.map(|g| self.visit_function(geom_from_text(g.wkt.clone(), g.srid, true))),
.map(|g| self.visit_function(geom_from_text(g.wkt.clone().raw(), g.srid.map(IntoRaw::raw), true))),
};

match res {
Expand Down Expand Up @@ -839,6 +839,7 @@ impl<'a> Visitor<'a> for Mssql<'a> {
self.write(if geom.geography { "geography" } else { "geometry" })?;
self.surround_with("::STGeomFromText(", ")", |ref mut s| {
s.visit_expression(*geom.wkt_expression)?;
s.write(",")?;
if geom.geography {
s.visit_expression(*geom.srid_expression.unwrap_or_else(|| Box::new(4326.into())))?;
} else {
Expand Down
4 changes: 2 additions & 2 deletions quaint/src/visitor/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ impl<'a> Visitor<'a> for Mysql<'a> {
// TODO@geometry: find a way to avoid cloning
ValueType::Geometry(g) => g
.as_ref()
.map(|g| self.visit_function(geom_from_text(g.wkt.clone(), g.srid, false))),
.map(|g| self.visit_function(geom_from_text(g.wkt.clone().raw(), g.srid.map(IntoRaw::raw), false))),
ValueType::Geography(g) => g
.as_ref()
.map(|g| self.visit_function(geom_from_text(g.wkt.clone(), g.srid, true))),
.map(|g| self.visit_function(geom_from_text(g.wkt.clone().raw(), g.srid.map(IntoRaw::raw), true))),
};

match res {
Expand Down
4 changes: 2 additions & 2 deletions quaint/src/visitor/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ impl<'a> Visitor<'a> for Postgres<'a> {
// TODO@geometry: find a way to avoid cloning
ValueType::Geometry(g) => g
.as_ref()
.map(|g| self.visit_function(geom_from_text(g.wkt.clone(), g.srid, false))),
.map(|g| self.visit_function(geom_from_text(g.wkt.clone().raw(), g.srid.map(IntoRaw::raw), false))),
ValueType::Geography(g) => g
.as_ref()
.map(|g| self.visit_function(geom_from_text(g.wkt.clone(), g.srid, true))),
.map(|g| self.visit_function(geom_from_text(g.wkt.clone().raw(), g.srid.map(IntoRaw::raw), true))),
};

match res {
Expand Down
4 changes: 2 additions & 2 deletions quaint/src/visitor/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ impl<'a> Visitor<'a> for Sqlite<'a> {
// TODO@geometry: find a way to avoid cloning
ValueType::Geometry(g) => g
.as_ref()
.map(|g| self.visit_function(geom_from_text(g.wkt.clone(), g.srid, false))),
.map(|g| self.visit_function(geom_from_text(g.wkt.clone().raw(), g.srid.map(IntoRaw::raw), false))),
ValueType::Geography(g) => g
.as_ref()
.map(|g| self.visit_function(geom_from_text(g.wkt.clone(), g.srid, true))),
.map(|g| self.visit_function(geom_from_text(g.wkt.clone().raw(), g.srid.map(IntoRaw::raw), true))),
};

match res {
Expand Down

0 comments on commit c7a5ed3

Please sign in to comment.