Fix doc test examples

This commit is contained in:
Timothy Warren 2019-04-11 20:57:02 -04:00
parent 8de03f883f
commit 2434f2cba8

View File

@ -24,7 +24,8 @@ enum QueryType {
/// The struct representing a query builder
#[derive(Debug)]
pub struct QueryBuilder {
state: QueryState,
/// The struct to store the query builder info
pub state: QueryState,
driver: Box<dyn DatabaseDriver>,
}
@ -53,11 +54,11 @@ impl QueryBuilder {
/// Set the fields to select from the database as a string
///
/// ```ignore
/// let mut qb = QueryBuilder::new(Driver::new());
///
/// ```
/// # let mut qb = stringqb::query_builder::QueryBuilder::default();
/// // You can also alias field names
/// qb.select("foo as bar")
/// qb.select("foo as bar");
/// # assert_eq!(qb.state.get_select_string(), r#""foo" as "bar""#);
/// ```
pub fn select(&mut self, fields: &str) -> &mut Self {
lazy_static! {
@ -86,7 +87,7 @@ impl QueryBuilder {
/// Set the fields to select from the database as a Vector
///
/// ```
/// # let mut qb = stringqb::QueryBuilder::default();
/// # let mut qb = stringqb::query_builder::QueryBuilder::default();
/// // You can also alias via a vector of fields
/// qb.select_vec(vec!["foo as bar", "baz"]);
/// # assert_eq!(qb.state.get_select_string(), r#""foo" as "bar","baz""#);
@ -105,11 +106,11 @@ impl QueryBuilder {
/// Specify the database table to select from
///
/// ```ignore
/// let mut qb = QueryBuilder::new(Driver::new());
///
/// // Specifiy an alias for the table
/// ```
/// # let mut qb = stringqb::query_builder::QueryBuilder::default();
/// // You can specifiy an alias for the table
/// qb.from("products p");
/// # assert_eq!(qb.state.get_from_string(), r#""products" "p""#);
/// ```
pub fn from(&mut self, table_name: &str) -> &mut Self {
let from_str = split_map_join(table_name, " ", |s| self.driver.quote_identifier(s));