Expand description
Diesel MySQL Spatial is an extension to Diesel that provides support for the MySQL flavour of OpenGIS spatial data types and the associated SQL functions.
§Declaring your schema
The types in diesel_mysql_spatial::sql_types
may be used in Diesel table!
macros.
If you use the diesel.toml
file for automatic schema generation, you need to add the
module to the import_types
list:
[print_schema]
## Add types from `diesel_mysql_spatial` like `LineString`
import_types = ["diesel::sql_types::*", "diesel_mysql_spatial::sql_types::*"]
§Constructing a query
This crate provides Diesel DSL functions for most spatial SQL functions.
They live in the dsl
module.
use diesel_mysql_spatial::dsl::ST_IsValid;
let valid_districts = districts.select(area).filter(ST_IsValid(area));
§Serializing and Deserializing
Diesel MySQL Spatial maps “Rust types” defined in the data_types
module (e.g.
diesel_mysql_spatial::data_types::Point
) to and from “SQL types” (e.g.
diesel_mysql_spatial::sql_types::Point
). The latter types are only used to represent a
SQL type. You should only put the structs in data_types
into your Queryable
structs.
Modules§
- data_
types - Structs that represent the Rust equivalent of spatial SQL types
- dsl
- Re-exports helper types and functions for SQL expressions
- functions
- MySQL specific spatial functions for use in SQL expressions
- helper_
types - Helper types that represent return types of spatial functions
- sql_
types - Spatial SQL types which may be used in table definitions
Enums§
- Geometry
Error - The error type for (de-)serialization and conversion errors of spatial datatypes.