pub struct DropIndex { /* private fields */ }Expand description
Builder to contruct a DropIndex command. Available only for the crate features postgresql and sqlite
Basic API
use sql_query_builder as sql;
let query = sql::DropIndex::new()
.drop_index("users_name_idx")
.as_string();
Output
DROP INDEX users_name_idxImplementations§
source§impl DropIndex
impl DropIndex
sourcepub fn drop_index(self, index_name: &str) -> Self
pub fn drop_index(self, index_name: &str) -> Self
Defines a drop index parameter, this method overrides the previous value
§Example 1
let query = sql::DropIndex::new()
.drop_index("users_name_idx")
.drop_index("orders_product_name_idx")
.as_string();
Outputs
DROP INDEX orders_product_name_idx§Example 2 crate features postgresql only
Multiples call will concatenates all values
let query = sql::DropIndex::new()
.drop_index("users_name_idx")
.drop_index("orders_product_name_idx")
.as_string();
Outputs
DROP INDEX users_name_idx, orders_product_name_idxsourcepub fn drop_index_if_exists(self, index_name: &str) -> Self
pub fn drop_index_if_exists(self, index_name: &str) -> Self
Defines a drop index parameter with the if exists modifier, this method overrides the previous value
§Example 1
let query = sql::DropIndex::new()
.drop_index("users_name_idx")
.drop_index_if_exists("orders_product_name_idx")
.to_string();
Outputs
DROP INDEX IF EXISTS orders_product_name_idx§Example 2 crate features postgresql only
Multiples call will concatenates all values
let query = sql::DropIndex::new()
.drop_index("users_name_idx")
.drop_index_if_exists("orders_product_name_idx")
.to_string();
Outputs
DROP INDEX IF EXISTS users_name_idx, orders_product_name_idxsourcepub fn debug(self) -> Self
pub fn debug(self) -> Self
Prints the current state of the DropIndex 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::DropIndex::new()
.drop_index("users_name_idx")
.debug()
.as_string();Prints to the standard output
-- ------------------------------------------------------------------------------
DROP INDEX users_name_idx
-- ------------------------------------------------------------------------------sourcepub fn print(self) -> Self
pub fn print(self) -> Self
Prints the current state of the DropIndex 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 index command.
§Example
let drop_index_query = sql::DropIndex::new()
.raw("/* drop index command */")
.drop_index("users_name_idx")
.as_string();
Output
/* drop index command */ DROP INDEX users_name_idxsourcepub fn raw_after(self, param: DropIndexParams, raw_sql: &str) -> Self
pub fn raw_after(self, param: DropIndexParams, raw_sql: &str) -> Self
Adds a raw SQL query after a specified parameter.
The DropIndexParams::DropIndex works both to .drop_index and .drop_index_if_exist methods
§Example
let query = sql::DropIndex::new()
.drop_index("users_name_idx")
.raw_after(sql::DropIndexParams::DropIndex, "/* end drop index */")
.as_string();
Output
DROP INDEX users_name_idx /* end drop index */sourcepub fn raw_before(self, param: DropIndexParams, raw_sql: &str) -> Self
pub fn raw_before(self, param: DropIndexParams, raw_sql: &str) -> Self
Adds a raw SQL query before a specified parameter.
The DropIndexParams::DropIndex works both to .drop_index and .drop_index_if_exist methods
§Example
let raw = "/* drop index command */";
let query = sql::DropIndex::new()
.raw_before(sql::DropIndexParams::DropIndex, raw)
.drop_index("users_name_idx")
.as_string();
Output
/* drop index command */ DROP INDEX users_name_idxTrait Implementations§
Auto Trait Implementations§
impl Freeze for DropIndex
impl RefUnwindSafe for DropIndex
impl Send for DropIndex
impl Sync for DropIndex
impl Unpin for DropIndex
impl UnwindSafe for DropIndex
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)