pub struct DropTable { /* private fields */ }Expand description
Builder to contruct a DropTable command
Basic API
use sql_query_builder as sql;
let query = sql::DropTable::new()
.drop_table("users")
.as_string();
Output
DROP TABLE usersImplementations§
source§impl DropTable
impl DropTable
sourcepub fn drop_table(self, table_name: &str) -> Self
pub fn drop_table(self, table_name: &str) -> Self
Defines a drop table parameter, this method overrides the previous value
§Example 1
let query = sql::DropTable::new()
.drop_table("users")
.drop_table("orders")
.as_string();
Outputs
DROP TABLE orders§Example 2 crate features postgresql only
Multiples call will concatenates all values
let query = sql::DropTable::new()
.drop_table("users")
.drop_table("orders")
.as_string();
Outputs
DROP TABLE users, orderssourcepub fn drop_table_if_exists(self, table_name: &str) -> Self
pub fn drop_table_if_exists(self, table_name: &str) -> Self
Defines a drop table parameter with the if exists modifier, this method overrides the previous value
§Example 1
let query = sql::DropTable::new()
.drop_table("users")
.drop_table_if_exists("orders")
.to_string();
Outputs
DROP TABLE IF EXISTS orders§Example 2 crate features postgresql only
Multiples call will concatenates all values
let query = sql::DropTable::new()
.drop_table("users")
.drop_table_if_exists("orders")
.to_string();
Outputs
DROP TABLE IF EXISTS users, orderssourcepub fn debug(self) -> Self
pub fn debug(self) -> Self
Prints the current state of the DropTable to the standard output in a more ease to read version. This method is useful to debug complex queries or just print the generated SQL while you type
§Example
let query = sql::DropTable::new()
.drop_table("users")
.debug()
.as_string();Prints to the standard output
-- ------------------------------------------------------------------------------
DROP TABLE users
-- ------------------------------------------------------------------------------sourcepub fn print(self) -> Self
pub fn print(self) -> Self
Prints the current state of the DropTable to the standard output similar to debug method, the difference is that this method prints in one line.
sourcepub fn raw(self, raw_sql: &str) -> Self
pub fn raw(self, raw_sql: &str) -> Self
Adds at the beginning a raw SQL query. Is useful to create a more complex drop table command.
§Example
let drop_table_query = sql::DropTable::new()
.raw("/* drop command */")
.drop_table("users_temp")
.as_string();
Output
/* drop command */ DROP TABLE users_tempsourcepub fn raw_after(self, param: DropTableParams, raw_sql: &str) -> Self
pub fn raw_after(self, param: DropTableParams, raw_sql: &str) -> Self
Adds a raw SQL query after a specified parameter.
The DropTableParams::DropTable works both to .drop_table and .drop_table_if_exist methods
§Example
let query = sql::DropTable::new()
.drop_table("users")
.raw_after(sql::DropTableParams::DropTable, "CASCADE")
.as_string();
Output
DROP TABLE users CASCADEsourcepub fn raw_before(self, param: DropTableParams, raw_sql: &str) -> Self
pub fn raw_before(self, param: DropTableParams, raw_sql: &str) -> Self
Adds a raw SQL query before a specified parameter.
The DropTableParams::DropTable works both to .drop_table and .drop_table_if_exist methods
§Example
let raw = "CREATE TABLE users_temp;";
let query = sql::DropTable::new()
.raw_before(sql::DropTableParams::DropTable, raw)
.drop_table("users_temp")
.as_string();
Output
CREATE TABLE users_temp; DROP TABLE users_tempTrait Implementations§
Auto Trait Implementations§
impl Freeze for DropTable
impl RefUnwindSafe for DropTable
impl Send for DropTable
impl Sync for DropTable
impl Unpin for DropTable
impl UnwindSafe for DropTable
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)