Skip to main content

drizzle_postgres/
lib.rs

1//! PostgreSQL support for drizzle-rs
2//!
3//! This crate provides PostgreSQL-specific types, query builders, and utilities.
4
5#![allow(unexpected_cfgs)]
6
7pub mod attrs;
8pub mod builder;
9pub mod common;
10pub mod expr;
11pub mod expressions;
12pub mod helpers;
13pub mod traits;
14pub mod values;
15
16#[cfg(all(feature = "postgres-sync", not(feature = "tokio-postgres")))]
17pub use postgres::Row;
18#[cfg(feature = "tokio-postgres")]
19pub use tokio_postgres::Row;
20
21pub use drizzle_core::ParamBind;
22
23/// Creates an array of SQL parameters for binding values to placeholders.
24///
25/// # Syntax
26/// - `{ name: value }` - Named parameter (creates :name placeholder)
27/// - `value` - Positional parameter (creates next positional placeholder)
28///
29/// # Examples
30///
31/// ```
32/// use drizzle_postgres::params;
33///
34/// let params = params![{ name: "alice" }, true];
35/// ```
36#[macro_export]
37macro_rules! params {
38    [$($param:tt),+ $(,)?] => {
39        [
40            $(
41                $crate::params_internal!($param)
42            ),+
43        ]
44    };
45}
46
47/// Internal helper macro for params! - converts items to ParamBind values
48#[macro_export]
49macro_rules! params_internal {
50    ({ $key:ident: $value:expr }) => {
51        $crate::ParamBind::new(
52            stringify!($key),
53            $crate::values::PostgresValue::from($value),
54        )
55    };
56    ($value:expr) => {
57        $crate::ParamBind::positional($crate::values::PostgresValue::from($value))
58    };
59}