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_idx