[][src]Struct sql_builder::name::SqlName

pub struct SqlName { /* fields omitted */ }

Create safe name of identifier

Examples

#[macro_use] extern crate sql_builder;
use sql_builder::{SqlBuilder, SqlName};

let sql = SqlBuilder::select_from(SqlName::new("public").add("BOOKS").alias("b").baquoted())
    .field(SqlName::new("b").add("title").baquoted())
    .field(SqlName::new("s").add("total").baquoted())
    .left()
    .join(SqlName::new("shops").alias("s").baquoted())
    .on_eq(SqlName::new("b").add("id").baquoted(), SqlName::new("s").add("book").baquoted())
    .sql()?;

assert_eq!("SELECT `b`.`title`, `s`.`total` FROM `public`.`BOOKS` AS b LEFT JOIN `shops` AS s ON `b`.`id` = `s`.`book`;", &sql);
#[macro_use] extern crate sql_builder;
use sql_builder::{SqlBuilder, SqlName};

let sql = SqlBuilder::select_from(baname!("public", "BOOKS"; "b"))
    .field(baname!("b", "title"))
    .field(baname!("s", "total"))
    .left()
    .join(baname!("shops"; "s"))
    .on_eq(baname!("b", "id"), baname!("s", "book"))
    .sql()?;

assert_eq!("SELECT `b`.`title`, `s`.`total` FROM `public`.`BOOKS` AS b LEFT JOIN `shops` AS s ON `b`.`id` = `s`.`book`;", &sql);

Implementations

impl SqlName[src]

pub fn new<S: ToString>(name: S) -> Self[src]

Name of identifier

pub fn add<S: ToString>(&mut self, name: S) -> &mut Self[src]

Add additional part of identifier

pub fn alias<S: ToString>(&mut self, alias: S) -> &mut Self[src]

Set an alias for identifier

pub fn safe(&self) -> String[src]

Make safe identifier

pub fn quoted(&self) -> String[src]

Make quoted identifier

pub fn baquoted(&self) -> String[src]

Make backquoted identifier

pub fn brquoted(&self) -> String[src]

Make bracket-quoted identifier

pub fn dquoted(&self) -> String[src]

Make double quoted identifier

Trait Implementations

impl Clone for SqlName[src]

Auto Trait Implementations

impl RefUnwindSafe for SqlName

impl Send for SqlName

impl Sync for SqlName

impl Unpin for SqlName

impl UnwindSafe for SqlName

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.