Skip to main content

Schema

Trait Schema 

Source
pub trait Schema:
    Clone
    + Send
    + Sync
    + Sized
    + 'static {
Show 21 methods // Required methods fn executor(&self) -> Option<&Executor>; fn set_executor(&mut self, executor: Executor) -> &mut Self; fn quote(&self, identifier: &str) -> Result<String>; fn quote_literal(&self, identifier: &str) -> Result<String>; fn compile_column_type(&self, column: &Column<Self>) -> Result<String>; fn compile_auto_increment(&self) -> &'static str; // Provided methods fn table(&self, name: impl Into<String>) -> Table<Self> { ... } fn compile_create( &self, table: &Table<Self>, if_not_exists: bool, ) -> Result<Statement> { ... } fn compile_alter(&self, table: &Table<Self>) -> Result<Statement> { ... } fn compile_drop(&self, name: &str, if_exists: bool) -> Result<Statement> { ... } fn compile_rename(&self, from: &str, to: &str) -> Result<Statement> { ... } fn compile_truncate(&self, name: &str) -> Result<Statement> { ... } fn create_index( &self, table: &str, name: &str, columns: &[&str], options: &IndexOptions, ) -> Result<Statement> { ... } fn drop_index(&self, table: &str, name: &str) -> Result<Statement> { ... } fn compile_column_definition(&self, column: &Column<Self>) -> Result<String> { ... } fn compile_generated_clause(&self, column: &Column<Self>) -> String { ... } fn compile_create_suffix(&self, _table: &Table<Self>) -> String { ... } fn quote_collation(&self, collation: &str) -> Result<String> { ... } fn literal(&self) -> StringLiteral { ... } fn compile_unsigned(&self) -> &'static str { ... } fn compile_index_columns(&self, index: &Index) -> Result<String> { ... }
}
Expand description

A dialect’s DDL compiler: quoting, column types, and the table, index and drop statements. Dialects override the steps they write differently; the provided methods are the shared (MySQL-flavoured) compilation.

Implement it (and the feature traits) to add a dialect.

PHP: the abstract Utopia\Query\Schema.

Required Methods§

Source

fn executor(&self) -> Option<&Executor>

The executor statements carry, if any.

Source

fn set_executor(&mut self, executor: Executor) -> &mut Self

Sets the executor every statement compiled from now on carries (Statement::execute runs it).

PHP: setExecutor().

Source

fn quote(&self, identifier: &str) -> Result<String>

Quotes a possibly qualified identifier.

PHP: quote().

Source

fn quote_literal(&self, identifier: &str) -> Result<String>

Quotes one identifier, dots included.

PHP: quoteLiteral().

Source

fn compile_column_type(&self, column: &Column<Self>) -> Result<String>

The SQL type of column.

PHP: compileColumnType().

Source

fn compile_auto_increment(&self) -> &'static str

The auto-increment keyword.

PHP: compileAutoIncrement().

Provided Methods§

Source

fn table(&self, name: impl Into<String>) -> Table<Self>

A blueprint of table name compiled by this schema.

PHP: table().

Source

fn compile_create( &self, table: &Table<Self>, if_not_exists: bool, ) -> Result<Statement>

CREATE TABLE [IF NOT EXISTS] for table.

PHP: compileCreate().

Source

fn compile_alter(&self, table: &Table<Self>) -> Result<Statement>

ALTER TABLE for table.

PHP: compileAlter().

Source

fn compile_drop(&self, name: &str, if_exists: bool) -> Result<Statement>

DROP TABLE [IF EXISTS] name.

PHP: compileDrop().

Source

fn compile_rename(&self, from: &str, to: &str) -> Result<Statement>

Renames table from to to.

PHP: compileRename().

Source

fn compile_truncate(&self, name: &str) -> Result<Statement>

Empties table name.

PHP: compileTruncate().

Source

fn create_index( &self, table: &str, name: &str, columns: &[&str], options: &IndexOptions, ) -> Result<Statement>

CREATE INDEX name ON table (columns) with options.

PHP: createIndex().

Source

fn drop_index(&self, table: &str, name: &str) -> Result<Statement>

Drops index name of table.

PHP: dropIndex().

Source

fn compile_column_definition(&self, column: &Column<Self>) -> Result<String>

The definition of column in CREATE / ALTER TABLE.

PHP: compileColumnDefinition().

Source

fn compile_generated_clause(&self, column: &Column<Self>) -> String

GENERATED ALWAYS AS (...) STORED|VIRTUAL.

PHP: compileGeneratedClause().

Source

fn compile_create_suffix(&self, _table: &Table<Self>) -> String

Clauses after the column list of CREATE TABLE (partitioning).

PHP: compileCreateSuffix().

Source

fn quote_collation(&self, collation: &str) -> Result<String>

A collation name as COLLATE takes it.

PHP: quoteCollation().

Source

fn literal(&self) -> StringLiteral

How the dialect writes a string literal: comments, defaults and enum values are inlined, since DDL takes no bound parameters.

PHP: $literal.

Source

fn compile_unsigned(&self) -> &'static str

The unsigned keyword, or empty where there is none.

PHP: compileUnsigned().

Source

fn compile_index_columns(&self, index: &Index) -> Result<String>

The column list of an index: lengths, collations, operator class, orders and raw expressions.

PHP: compileIndexColumns().

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§