Skip to main content
With feature = "spatial", the crate exposes DuckDB’s spatial ST_* functions as typed Diesel DSL. Unlike the rest of the DSL, these are not in the dsl::* prelude — import them from better_duck_diesel::spatial::*. GEOMETRY values travel as WKB, so geometry arguments and results are typed Binary.

Loading the extension

ensure_loaded(conn) installs and loads DuckDB’s spatial extension at runtime. Call it once per connection before using any ST_* function.
ensure_loaded returns Err when the extension cannot be made available — most often offline, because the install step needs network access unless the extension is already present. Handle the error gracefully (the crate’s own spatial tests skip rather than fail in that case). In a pool, run it from the on_connect hook so every connection is ready.

Functions

feature = "spatial" carries no extra Rust dependencies — it only gates this module. The ST_* functions are plain SQL and the geometry round-trips as WKB Binary.

See also

Feature flags

What spatial enables.

Pooling

ensure_loaded per pooled connection.

Extensions (core)

Loading DuckDB extensions at the driver level.

DSL overview

The non-spatial DSL.