Enum rorm_sql::DBImpl

source ·
pub enum DBImpl {
    SQLite,
    Postgres,
    MySQL,
}
Expand description

The main interface for creating sql strings

Variants§

§

SQLite

Implementation of SQLite

§

Postgres

Implementation of Postgres

§

MySQL

Implementation of MySQL / MariaDB

Implementations§

The entry point to create a table.

Parameter:

  • name: Name of the table

The entry point to create a trigger.

Parameter:

Examples found in repository?
src/create_trigger.rs (lines 130-135)
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
pub(crate) fn trigger_annotation_to_trigger_sqlite(
    annotation: &Annotation,
    db_type: &DbType,
    table_name: &str,
    column_name: &str,
    statements: &mut Vec<(String, Vec<Value>)>,
) {
    if annotation == &Annotation::AutoUpdateTime {
        let update_statement = format!(
            "UPDATE {} SET {} = {} WHERE ROWID = NEW.ROWID;",
            table_name,
            column_name,
            match db_type {
                DbType::Date => "CURRENT_DATE",
                DbType::DateTime => "CURRENT_TIMESTAMP",
                DbType::Timestamp => "CURRENT_TIMESTAMP",
                DbType::Time => "CURRENT_TIME",
                _ => "",
            }
        );
        statements.push((
            DBImpl::SQLite
                .create_trigger(
                    format!("{}_{}_auto_update_time", table_name, column_name).as_str(),
                    table_name,
                    Some(SQLCreateTriggerPointInTime::After),
                    SQLCreateTriggerOperation::Update { columns: None },
                )
                .for_each_row()
                .if_not_exists()
                .add_statement(update_statement)
                .build(),
            vec![],
        ))
    }
}

The entry point to create an index.

Parameter:

  • name: Name of the index.
  • table_name: Table to create the index on.

The entry point to drop a table.

Parameter:

  • name: Name of the table to drop.

The entry point to alter a table.

Parameter:

  • name: Name of the table to execute the operation on.
  • operation: AlterTableOperation: The operation to execute.

The entry point to create a column in a table.

Parameter:

  • table_name: Name of the table.
  • name: Name of the column.
  • data_type: DbType: Data type of the column
  • annotations: slice of Annotation: List of annotations.

Build a select query.

Parameter:

  • columns: The columns to select.
  • from_clause: Specifies from what to select. This can be a table name or another query itself.
  • joins: List of join tables.

Build an INSERT query.

Parameter:

  • into_clause: The table to insert into.
  • insert_columns: The column names to insert into.
  • insert_values: slice of slice of Value: The values to insert.
  • returning_clause: Optional slice of string to retrieve after the insert.

Build a delete operation.

Parameter:

  • table_name: Name of the table to delete from.

Build an update operation.

Parameter:

  • table_name: Name of the table the updates should be executed for.

The entry point for a JOIN expression builder.

Parameter:

  • join_type: JoinType: Type for a JOIN expression
  • table_name: Table to perform the join on
  • join_alias: Alias for the join table
  • join_condition: Condition to apply to the join

The entry point for a column selector builder.

Parameter:

  • table_name: Optional table name
  • column_name: Name of the column
  • select_alias: Alias for the selector
  • aggregation: Optional aggregation function

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.