Expand description
SQL generation utilities.
This module provides optimized SQL generation with:
- Pre-allocated string buffers
- Zero-copy placeholder generation for common cases
- Batch placeholder generation for IN clauses
- SQL template caching for common query patterns
Modules§
- templates
- Pre-built SQL templates for common query patterns.
Structs§
- Fast
SqlBuilder - An optimized SQL builder that uses a single String buffer.
- SqlBuilder
- A SQL builder for constructing queries.
Enums§
- Database
Type - Build a parameter placeholder for a given database type.
- Query
Capacity - Capacity hints for different query types.
Constants§
- MYSQL_
IN_ PATTERNS - Pre-computed IN clause placeholder patterns for MySQL/SQLite. Format: “?, ?, ?, …” for common sizes (1-32 elements).
- POSTGRES_
PLACEHOLDERS - Pre-computed PostgreSQL placeholder strings for indices 1-256.
This avoids
format!calls for the most common parameter counts. Index 0 is unused (placeholders start at $1), but kept for simpler indexing. Pre-computed PostgreSQL parameter placeholders ($1-$256).
Functions§
- escape_
identifier - Escape a string for use in SQL (for identifiers, not values).
- needs_
quoting - Check if an identifier needs quoting.
- postgres_
in_ pattern - Get a pre-computed PostgreSQL IN placeholder pattern. Returns patterns like “$1, $2, $3” for count=3 starting at start_idx=1.
- quote_
identifier - Quote an identifier if needed.
- write_
postgres_ in_ pattern - Write PostgreSQL IN placeholders directly to a buffer.