Skip to main content

MySql

Struct MySql 

Source
pub struct MySql { /* private fields */ }
Expand description

The MySQL schema: backtick quoting, AUTO_INCREMENT, inline indexes, PARTITION BY ... PARTITIONS n.

use utopia_query::schema::{MySql, Schema};

let schema = MySql::new();
let mut table = schema.table("events");
table.id("id");
table.json("payload").nullable();
table.partition_by_hash("id", Some(4))?;
assert_eq!(
    table.create()?.query,
    "CREATE TABLE `events` (`id` BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, `payload` JSON NULL, \
     PRIMARY KEY (`id`)) PARTITION BY HASH(id) PARTITIONS 4"
);
use Utopia\Query\Schema\MySQL;

$table = (new MySQL())->table('events');
$table->id();
$table->json('payload')->nullable();
$table->partitionByHash('id', 4);
echo $table->create()->query, "\n";

PHP: Utopia\Query\Schema\MySQL.

Implementations§

Source§

impl MySql

Source

pub fn new() -> Self

A MySQL schema without an executor.

PHP: new MySQL().

Source

pub fn change_column( &self, table: &str, old_name: &str, new_name: &str, kind: &str, ) -> Result<Statement>

ALTER TABLE table CHANGE COLUMN old new type: renames and retypes a column (kind is emitted verbatim).

PHP: changeColumn().

Source

pub fn modify_column( &self, table: &str, name: &str, kind: &str, ) -> Result<Statement>

ALTER TABLE table MODIFY name type: retypes a column (kind is emitted verbatim).

PHP: MySQL::modifyColumn().

Trait Implementations§

Source§

impl AnalyzeTable for MySql

Source§

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

Analyzes table. Read more
Source§

impl AutoIncrement for MySql

Source§

impl Checks for MySql

Source§

impl Clone for MySql

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Collation for MySql

Source§

impl ColumnAlterations for MySql

Source§

impl Comment for MySql

Source§

impl CompositePrimary for MySql

Source§

impl CreatePartition for MySql

Source§

fn create_partition( &self, parent: &str, name: &str, expression: &str, ) -> Result<Statement>

Adds partition name of parent for expression. Read more
Source§

impl Databases for MySql

Source§

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

Creates database name. Read more
Source§

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

Drops database name. Read more
Source§

impl Debug for MySql

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MySql

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl DropPartition for MySql

Source§

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

Drops partition name of table. Read more
Source§

impl ForeignKeys for MySql

Source§

impl ForeignKeys for MySql

Source§

fn add_foreign_key( &self, table: &str, name: &str, key: &ForeignKey, ) -> Result<Statement>

ALTER TABLE table ADD CONSTRAINT name FOREIGN KEY ... for key. Read more
Source§

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

Drops the foreign key name of table. Read more
Source§

impl FulltextSpatialIndex for MySql

Source§

impl Generated for MySql

Source§

impl InlineForeignKey for MySql

Source§

impl Partitioning for MySql

Source§

fn compile_create_partitioning(&self, table: &Table<Self>) -> String

The PARTITION BY ... clause of table, or empty. Read more
Source§

impl Positioning for MySql

Source§

impl Procedures for MySql

Source§

fn create_procedure( &self, name: &str, params: &[(ParameterDirection, &str, &str)], body: &str, ) -> Result<Statement>

Creates procedure name with params (direction, name, SQL type) and body, which is emitted verbatim and must be trusted. Read more
Source§

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

Drops procedure name. Read more
Source§

impl RenameIndex for MySql

Source§

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

Renames index from of table to to. Read more
Source§

impl ReplaceView for MySql

Source§

fn create_or_replace_view( &self, name: &str, query: &mut dyn AnyBuilder, ) -> Result<Statement>

Creates or replaces view name of the query query builds. Read more
Source§

impl Schema for MySql

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). Read more
Source§

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

Quotes a possibly qualified identifier. Read more
Source§

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

Quotes one identifier, dots included. Read more
Source§

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

The SQL type of column. Read more
Source§

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

The auto-increment keyword. Read more
Source§

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

Clauses after the column list of CREATE TABLE (partitioning). Read more
Source§

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

A blueprint of table name compiled by this schema. Read more
Source§

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

CREATE TABLE [IF NOT EXISTS] for table. Read more
Source§

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

ALTER TABLE for table. Read more
Source§

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

DROP TABLE [IF EXISTS] name. Read more
Source§

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

Renames table from to to. Read more
Source§

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

Empties table name. Read more
Source§

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

CREATE INDEX name ON table (columns) with options. Read more
Source§

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

Drops index name of table. Read more
Source§

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

The definition of column in CREATE / ALTER TABLE. Read more
Source§

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

GENERATED ALWAYS AS (...) STORED|VIRTUAL. Read more
Source§

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

A collation name as COLLATE takes it. Read more
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. Read more
Source§

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

The unsigned keyword, or empty where there is none. Read more
Source§

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

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

impl Serial for MySql

Source§

impl Srid for MySql

Source§

impl StandardPartitioning for MySql

Source§

impl TableComments for MySql

Source§

fn comment_on_table(&self, table: &str, comment: &str) -> Result<Statement>

Sets the comment of table. Read more
Source§

impl Triggers for MySql

Source§

fn create_trigger( &self, name: &str, table: &str, timing: TriggerTiming, event: TriggerEvent, body: &str, ) -> Result<Statement>

Creates trigger name on table, running body (verbatim, trusted) for each row at timing of event. Read more
Source§

fn drop_trigger(&self, name: &str, _table: Option<&str>) -> Result<Statement>

Drops trigger name (PostgreSQL needs its table). Read more
Source§

impl Unique for MySql

Source§

impl Views for MySql

Source§

fn create_view( &self, name: &str, query: &mut dyn AnyBuilder, ) -> Result<Statement>

Creates view name of the query query builds (its bindings ride along). Read more
Source§

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

Drops view name. Read more
Source§

impl VirtualGenerated for MySql

Auto Trait Implementations§

§

impl !RefUnwindSafe for MySql

§

impl !UnwindSafe for MySql

§

impl Forget for MySql

§

impl Freeze for MySql
where *const ArcInner<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send>>: Freeze,

§

impl Move for MySql

§

impl Send for MySql
where Arc<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send>: Send,

§

impl Sync for MySql
where Arc<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send>: Sync,

§

impl Unpin for MySql
where Arc<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send>: Unpin,

§

impl UnsafeUnpin for MySql
where *const ArcInner<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn(&Statement) -> Result<Value<Object>, Error> + Sync + Send>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.