Struct sql_migration_sim::Schema

source ·
pub struct Schema {
    pub dialect: Box<dyn Dialect>,
    pub tables: HashMap<String, Table>,
    pub views: HashMap<String, View>,
    pub indices: HashMap<String, String>,
    pub functions: HashMap<String, Function>,
    pub creation_order: Vec<ObjectNameAndType>,
}
Expand description

The database schema, built from parsing one or more SQL statements.

Fields§

§dialect: Box<dyn Dialect>

The SQL dialect used for pasing

§tables: HashMap<String, Table>

The tables in the schema

§views: HashMap<String, View>

The views in the schema

§indices: HashMap<String, String>

The created indices. The key is the index name and the value is the table the index is on.

§functions: HashMap<String, Function>

Functions in the schema

§creation_order: Vec<ObjectNameAndType>

References to the schema objects, in the order they were created.

Implementations§

source§

impl Schema

source

pub fn new() -> Self

Create a new Schema that parses with a generic SQL dialect

source

pub fn new_with_dialect<D: Dialect>(dialect: D) -> Self

Create a new Schema that parses with the given SQL dialect

source

pub fn apply_statement(&mut self, statement: Statement) -> Result<(), Error>

Apply a parsed statement to the schema

source

pub fn parse_sql(&self, sql: &str) -> Result<Vec<Statement>, Error>

Parse some SQL into a list of statements

source

pub fn apply_sql(&mut self, sql: &str) -> Result<(), Error>

Apply one or more SQL statements to the schema

source

pub fn apply_file(&mut self, filename: &Path) -> Result<(), Error>

Read a SQL file and apply its contents to the schema

Trait Implementations§

source§

impl Debug for Schema

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Schema

§

impl !RefUnwindSafe for Schema

§

impl !Send for Schema

§

impl !Sync for Schema

§

impl Unpin for Schema

§

impl !UnwindSafe for Schema

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.