pub struct CreateTable { /* private fields */ }
Expand description
Represents the creation of a table with specified columns and options.
Implementations§
Source§impl CreateTable
impl CreateTable
Sourcepub fn new(table: &str, columns: Vec<Column>) -> Self
pub fn new(table: &str, columns: Vec<Column>) -> Self
Creates a new CreateTable
instance with the given table name and columns.
§Example
use lumus_sql_builder::sqlite::{CreateTable, Column};
let create_table = CreateTable::new("users", vec![
Column::new("name").text().not_null().primary_key(),
]).build().unwrap();
assert_eq!(create_table, "CREATE TABLE users (name TEXT NOT NULL PRIMARY KEY);");
Sourcepub fn if_not_exists(self) -> Self
pub fn if_not_exists(self) -> Self
Specifies that the table should be created only if it does not already exist.
Sourcepub fn build(&self) -> Result<String, SqlBuilderError>
pub fn build(&self) -> Result<String, SqlBuilderError>
Builds and returns the SQL statement for creating the table.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CreateTable
impl RefUnwindSafe for CreateTable
impl Send for CreateTable
impl Sync for CreateTable
impl Unpin for CreateTable
impl UnwindSafe for CreateTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more