sea-query-hyper
HyperDB SQL dialect backend for sea-query.
This crate provides HyperQueryBuilder, a sea-query backend that generates SQL
compatible with HyperDB's SQL dialect. HyperDB is largely PostgreSQL-compatible,
so this builder currently delegates to PostgresQueryBuilder for all operations.
As Hyper's SQL dialect evolves, this builder will be updated to emit Hyper-specific
syntax where needed.
Quick Start
[]
= "0.1"
= "0.30"
use ;
use HyperQueryBuilder;
let query = select
.column
.column
.from
.and_where
.to_owned;
// Build with parameter placeholders ($1, $2, ...)
let = query.build;
// Or get the SQL string with values inlined
let sql_string = query.to_string;
Usage with hyperdb-api
Build queries with sea-query, convert to SQL strings, and pass them to
hyperdb-api connection methods:
use Connection;
use ;
use HyperQueryBuilder;
let query = select
.columns
.from
.and_where
.and_where
.order_by
.limit
.to_owned;
let sql = query.to_string;
let result = conn.execute_query?;
HyperDB-Specific Dialect
Use HyperQueryBuilder instead of PostgresQueryBuilder so your code
automatically picks up Hyper-specific syntax as the dialect evolves. Both produce
identical SQL today.
HyperQueryBuilder implements all sea-query backend traits:
QueryBuilder-- SELECT, INSERT, UPDATE, DELETESchemaBuilder-- CREATE TABLE, ALTER TABLE, DROP TABLEGenericBuilder-- full builder interface combining query and schema
Advanced Features
Sea-query supports advanced SQL features that work with HyperQueryBuilder.
Window functions:
use ;
let sql = select
.columns
.expr_as
.from
.to_string;
Complex JOINs:
use ;
let sql = select
.columns
.from
.inner_join
.to_string;
Aggregates with GROUP BY / HAVING:
let sql = select
.column
.expr_as
.from
.group_by_col
.and_having
.to_string;
HyperDB Limitations
When using sea-query with HyperDB, be aware of these architectural constraints:
- No indexes --
CREATE INDEXis accepted but has no performance effect - No primary/foreign/unique keys -- constraint definitions are accepted but not enforced
- Limited ALTER TABLE -- some column modifications may not be supported
When to Use sea-query
| Use Case | Recommended Approach |
|---|---|
| Simple CRUD operations | Raw SQL strings |
| Basic analytics (GROUP BY, aggregates) | Raw SQL strings |
| Complex reporting with window functions | sea-query + sea-query-hyperdb |
| CTEs or nested subqueries | sea-query + sea-query-hyperdb |
| Type-safe, composable query building | sea-query + sea-query-hyperdb |
Examples
Related Documentation
- sea-query docs -- sea-query crate documentation
- hyperdb-api -- high-level Hyper database API
License
Licensed under either of Apache License, Version 2.0 or MIT license, at your option.