Skip to main content

SyncTargetAdapter

Trait SyncTargetAdapter 

Source
pub trait SyncTargetAdapter: Send + Sync {
    // Required methods
    fn ir_type_to_native(&self, ir_type: &IRType) -> String;
    fn format_default(&self, default: &IRDefault) -> Option<String>;
    fn format_literal(&self, value: &Option<Value>, ir_type: &IRType) -> String;

    // Provided methods
    fn quote_char(&self) -> char { ... }
    fn quote_ident(&self, name: &str) -> String { ... }
    fn supports_primary_key(&self) -> bool { ... }
    fn auto_increment_keyword(&self) -> Option<&str> { ... }
    fn create_table_suffix(&self, ir_table: &IRTable) -> Option<String> { ... }
    fn transform_value(
        &self,
        value: &Option<Value>,
        _ir_type: &IRType,
    ) -> Option<Value> { ... }
}
Expand description

Renders IR back into native DDL fragments (used for the target side of a sync).

Required Methods§

Source

fn ir_type_to_native(&self, ir_type: &IRType) -> String

Render an IRType as a native DDL type string.

Source

fn format_default(&self, default: &IRDefault) -> Option<String>

Render an IRDefault as the content of a DEFAULT clause. Return None to omit the clause entirely (e.g. for auto-increment columns whose default is handled by the database engine).

Source

fn format_literal(&self, value: &Option<Value>, ir_type: &IRType) -> String

Format a runtime Value as a SQL literal suitable for INSERT statements.

Provided Methods§

Source

fn quote_char(&self) -> char

Source

fn quote_ident(&self, name: &str) -> String

Source

fn supports_primary_key(&self) -> bool

Whether the target database supports inline PRIMARY KEY constraints in CREATE TABLE. OLAP engines typically do not.

Source

fn auto_increment_keyword(&self) -> Option<&str>

Keyword appended after the column type for auto-increment columns. Return None if the engine uses a different mechanism (e.g. PG SERIAL/IDENTITY).

Source

fn create_table_suffix(&self, ir_table: &IRTable) -> Option<String>

Appended after CREATE TABLE (...) closing paren. Default: use ir_table.table_options if present.

Source

fn transform_value( &self, value: &Option<Value>, _ir_type: &IRType, ) -> Option<Value>

Optional value transform before formatting literals (identity by default).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§