2019-04-02 16:35:52 -04:00
|
|
|
//! # StringQB
|
|
|
|
//!
|
|
|
|
//! A query builder using mostly strings, with methods following common SQL syntax
|
2019-04-17 11:33:25 -04:00
|
|
|
//!
|
2019-07-24 09:51:53 -04:00
|
|
|
//! Drivers include:
|
|
|
|
//! * `PostgresDriver` - for PostgreSQL databases
|
|
|
|
//! * `MySQLDriver` - for MySQL/MariaDB databases
|
|
|
|
//! * `SQLiteDriver` - for SQLite databases
|
2019-04-22 08:59:40 -04:00
|
|
|
//!
|
2019-07-24 09:51:53 -04:00
|
|
|
//! Example:
|
2019-04-22 08:59:40 -04:00
|
|
|
//! ```no_run
|
2019-04-17 11:33:25 -04:00
|
|
|
//! use stringqb::prelude::*;
|
|
|
|
//!
|
2019-07-24 09:51:53 -04:00
|
|
|
//! // Create the database driver object (Postgres is enabled by default)
|
|
|
|
//! let pgDriver = PostgresDriver::new("postgres://user:pass@host:port/database");
|
2019-04-17 11:33:25 -04:00
|
|
|
//!
|
2019-07-24 09:51:53 -04:00
|
|
|
//! // The query builder must be mutable to be useful
|
|
|
|
//! let mut qb = QueryBuilder::new(pgDriver);
|
2019-04-22 08:59:40 -04:00
|
|
|
//!
|
2019-07-24 09:51:53 -04:00
|
|
|
//! // Each builder method returns a mutable reference to itself so
|
|
|
|
//! // the methods are chainable
|
|
|
|
//! qb.select("field as f")
|
|
|
|
//! .from("table t")
|
|
|
|
//! .inner_join("table_two tt", "field2 as ff", "=", "f")
|
|
|
|
//! .wher("f >", 3);
|
|
|
|
//!
|
|
|
|
//! // Since they are references, you do not have to chain.
|
|
|
|
//! let sql = qb.get_compiled_select();
|
|
|
|
//! ```
|
2019-04-10 14:03:28 -04:00
|
|
|
#![warn(missing_docs)]
|
2019-04-02 16:35:52 -04:00
|
|
|
|
2019-04-11 17:16:35 -04:00
|
|
|
#[macro_use]
|
|
|
|
extern crate lazy_static;
|
|
|
|
|
2019-07-18 09:36:59 -04:00
|
|
|
#[cfg(feature = "sqlite")]
|
|
|
|
#[macro_use]
|
|
|
|
extern crate slite;
|
|
|
|
|
2019-04-02 16:35:52 -04:00
|
|
|
pub mod drivers;
|
2019-04-12 15:25:59 -04:00
|
|
|
pub mod fns;
|
2019-04-02 16:35:52 -04:00
|
|
|
pub mod query_builder;
|
2019-04-24 16:12:07 -04:00
|
|
|
pub mod types;
|
2019-04-09 17:14:07 -04:00
|
|
|
|
2019-04-12 15:25:59 -04:00
|
|
|
pub mod prelude {
|
|
|
|
//! Re-exports important traits and types.
|
2019-04-12 17:09:59 -04:00
|
|
|
//!
|
|
|
|
//! This includes enum types, traits,
|
|
|
|
//! the Query Builder, and individual database drivers.
|
|
|
|
pub use crate::drivers::DatabaseDriver;
|
2019-07-19 12:45:18 -04:00
|
|
|
pub use crate::query_builder::{JoinType, LikeWildcard, OrderDirection, QueryBuilder};
|
2019-04-12 17:09:59 -04:00
|
|
|
|
|
|
|
#[cfg(feature = "postgres")]
|
2019-04-17 11:33:25 -04:00
|
|
|
/// Postgres Driver
|
2019-04-12 17:09:59 -04:00
|
|
|
pub use crate::drivers::postgres::PostgresDriver;
|
|
|
|
|
|
|
|
#[cfg(feature = "sqlite")]
|
2019-04-17 11:33:25 -04:00
|
|
|
/// SQLite Driver
|
2019-04-12 17:09:59 -04:00
|
|
|
pub use crate::drivers::sqlite::SQLiteDriver;
|
|
|
|
|
|
|
|
#[cfg(feature = "mysql")]
|
2019-04-17 11:33:25 -04:00
|
|
|
/// MySQL Driver
|
2019-04-12 17:09:59 -04:00
|
|
|
pub use crate::drivers::mysql::MySQLDriver;
|
|
|
|
|
|
|
|
// MSSQL is missing on purpose, as it is not a real priority to actually implement
|
2019-04-09 17:33:26 -04:00
|
|
|
}
|