pub struct ColumnMapping {
pub column_name: String,
pub expression: Option<String>,
}Expand description
Defines how a column receives its value during insertion.
Column mappings allow you to:
- Insert values directly from the inserter stream
- Compute values using SQL expressions
- Use server-side functions like
NOW()orDEFAULT
§Example
use hyperdb_api::ColumnMapping;
// Simple column - insert value directly
let id_col = ColumnMapping::new("id");
// Column with expression - computed value
let created_at = ColumnMapping::with_expression("created_at", "NOW()");
let full_name = ColumnMapping::with_expression("full_name", "first_name || ' ' || last_name");Fields§
§column_name: StringThe name of the target column.
expression: Option<String>Optional SQL expression. If None, the value is inserted directly.
Implementations§
Source§impl ColumnMapping
impl ColumnMapping
Sourcepub fn new(column_name: impl Into<String>) -> Self
pub fn new(column_name: impl Into<String>) -> Self
Creates a column mapping for direct value insertion.
The column will receive values directly from the inserter.
Sourcepub fn with_expression(
column_name: impl Into<String>,
expression: impl Into<String>,
) -> Self
pub fn with_expression( column_name: impl Into<String>, expression: impl Into<String>, ) -> Self
Creates a column mapping with a SQL expression.
The column value will be computed using the given SQL expression. The expression can reference other columns or use SQL functions.
§Arguments
column_name- The name of the target column.expression- A SQL expression to compute the column value.
§Example
use hyperdb_api::ColumnMapping;
// Use current timestamp
let created = ColumnMapping::with_expression("created_at", "NOW()");
// Compute from other columns
let total = ColumnMapping::with_expression("total", "quantity * price");Sourcepub fn column_name(&self) -> &str
pub fn column_name(&self) -> &str
Returns the column name.
Sourcepub fn expression(&self) -> Option<&str>
pub fn expression(&self) -> Option<&str>
Returns the SQL expression, if any.
Trait Implementations§
Source§impl Clone for ColumnMapping
impl Clone for ColumnMapping
Source§fn clone(&self) -> ColumnMapping
fn clone(&self) -> ColumnMapping
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ColumnMapping
impl RefUnwindSafe for ColumnMapping
impl Send for ColumnMapping
impl Sync for ColumnMapping
impl Unpin for ColumnMapping
impl UnsafeUnpin for ColumnMapping
impl UnwindSafe for ColumnMapping
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request