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§
Sourcefn set_executor(&mut self, executor: Executor) -> &mut Self
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().
Sourcefn quote(&self, identifier: &str) -> Result<String>
fn quote(&self, identifier: &str) -> Result<String>
Quotes a possibly qualified identifier.
PHP: quote().
Sourcefn quote_literal(&self, identifier: &str) -> Result<String>
fn quote_literal(&self, identifier: &str) -> Result<String>
Quotes one identifier, dots included.
PHP: quoteLiteral().
Sourcefn compile_column_type(&self, column: &Column<Self>) -> Result<String>
fn compile_column_type(&self, column: &Column<Self>) -> Result<String>
The SQL type of column.
PHP: compileColumnType().
Sourcefn compile_auto_increment(&self) -> &'static str
fn compile_auto_increment(&self) -> &'static str
The auto-increment keyword.
PHP: compileAutoIncrement().
Provided Methods§
Sourcefn table(&self, name: impl Into<String>) -> Table<Self>
fn table(&self, name: impl Into<String>) -> Table<Self>
A blueprint of table name compiled by this schema.
PHP: table().
Sourcefn compile_create(
&self,
table: &Table<Self>,
if_not_exists: bool,
) -> Result<Statement>
fn compile_create( &self, table: &Table<Self>, if_not_exists: bool, ) -> Result<Statement>
CREATE TABLE [IF NOT EXISTS] for table.
PHP: compileCreate().
Sourcefn compile_alter(&self, table: &Table<Self>) -> Result<Statement>
fn compile_alter(&self, table: &Table<Self>) -> Result<Statement>
ALTER TABLE for table.
PHP: compileAlter().
Sourcefn compile_drop(&self, name: &str, if_exists: bool) -> Result<Statement>
fn compile_drop(&self, name: &str, if_exists: bool) -> Result<Statement>
DROP TABLE [IF EXISTS] name.
PHP: compileDrop().
Sourcefn compile_rename(&self, from: &str, to: &str) -> Result<Statement>
fn compile_rename(&self, from: &str, to: &str) -> Result<Statement>
Renames table from to to.
PHP: compileRename().
Sourcefn compile_truncate(&self, name: &str) -> Result<Statement>
fn compile_truncate(&self, name: &str) -> Result<Statement>
Empties table name.
PHP: compileTruncate().
Sourcefn create_index(
&self,
table: &str,
name: &str,
columns: &[&str],
options: &IndexOptions,
) -> Result<Statement>
fn create_index( &self, table: &str, name: &str, columns: &[&str], options: &IndexOptions, ) -> Result<Statement>
CREATE INDEX name ON table (columns) with options.
PHP: createIndex().
Sourcefn drop_index(&self, table: &str, name: &str) -> Result<Statement>
fn drop_index(&self, table: &str, name: &str) -> Result<Statement>
Drops index name of table.
PHP: dropIndex().
Sourcefn compile_column_definition(&self, column: &Column<Self>) -> Result<String>
fn compile_column_definition(&self, column: &Column<Self>) -> Result<String>
The definition of column in CREATE / ALTER TABLE.
PHP: compileColumnDefinition().
Sourcefn compile_generated_clause(&self, column: &Column<Self>) -> String
fn compile_generated_clause(&self, column: &Column<Self>) -> String
GENERATED ALWAYS AS (...) STORED|VIRTUAL.
PHP: compileGeneratedClause().
Sourcefn compile_create_suffix(&self, _table: &Table<Self>) -> String
fn compile_create_suffix(&self, _table: &Table<Self>) -> String
Clauses after the column list of CREATE TABLE (partitioning).
PHP: compileCreateSuffix().
Sourcefn quote_collation(&self, collation: &str) -> Result<String>
fn quote_collation(&self, collation: &str) -> Result<String>
A collation name as COLLATE takes it.
PHP: quoteCollation().
Sourcefn literal(&self) -> StringLiteral
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.
Sourcefn compile_unsigned(&self) -> &'static str
fn compile_unsigned(&self) -> &'static str
The unsigned keyword, or empty where there is none.
PHP: compileUnsigned().
Sourcefn compile_index_columns(&self, index: &Index) -> Result<String>
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".