Add public method signatures, subject to change

This commit is contained in:
Timothy Warren 2019-04-03 13:29:08 -04:00
parent ff5a9354c5
commit 88bcd5f0fb
1 changed files with 196 additions and 6 deletions

View File

@ -6,6 +6,27 @@ use std::collections::HashMap;
use crate::drivers::DatabaseDriver;
#[derive(Debug)]
pub enum LikeWildcard {
Before,
After,
Both,
}
#[derive(Debug)]
pub enum JoinType {
Inner,
Outer,
Left,
Right,
}
#[derive(Debug)]
pub enum OrderDirection {
Asc,
Desc,
}
#[derive(Debug)]
enum QueryClauseType {
AndGroupStart,
@ -80,11 +101,97 @@ impl QueryBuilder {
}
}
// --------------------------------------------------------------------------
// ! Select Queries
// --------------------------------------------------------------------------
/// Set the fields to select from the database
pub fn select(mut self, fields: &str) -> Self {
unimplemented!();
}
// Adds the 'distinct' keyword to a query
pub fn distinct(mut self) -> Self {
unimplemented!();
}
/// Specify the database table to select from
pub fn from(mut self, table_name: &str) -> Self {
// @TODO properly escape the table name
self.state.from_string = table_name.to_string();
self
}
// --------------------------------------------------------------------------
// ! 'Like' methods
// --------------------------------------------------------------------------
// Creates a like clause in the sql statement
pub fn like(mut self, field: &str, value: Box<dyn Any>, position: LikeWildcard) -> Self {
unimplemented!();
}
// Generates an OR Like clause
pub fn or_like(mut self, field: &str, value: Box<dyn Any>, position: LikeWildcard) -> Self {
unimplemented!();
}
// Generates a NOI Like clause
pub fn not_like(mut self, field: &str, value: Box<dyn Any>, position: LikeWildcard) -> Self {
unimplemented!();
}
// Generates an OR NOT Like clause
pub fn or_not_like(mut self, field: &str, value: Box<dyn Any>, position: LikeWildcard) -> Self {
unimplemented!();
}
// --------------------------------------------------------------------------
// ! Having methods
// --------------------------------------------------------------------------
pub fn having(mut self, key:&str, value: Box<dyn Any>) -> Self {
unimplemented!();
}
pub fn or_having(mut self, key:&str, value: Box<dyn Any>) -> Self {
unimplemented!();
}
// --------------------------------------------------------------------------
// ! 'Where' methods
// --------------------------------------------------------------------------
/// Specify a condition for the where clause of the query
pub fn r#where(mut self, key: &str, value: Box<dyn Any>) -> Self {
unimplemented!();
}
pub fn or_where(mut self, key: &str, value: Box<dyn Any>) -> Self {
unimplemented!();
}
pub fn where_in(mut self, key: &str, value: Vec<Box<dyn Any>>) -> Self {
unimplemented!();
}
pub fn or_where_in(mut self, key: &str, value: Vec<Box<dyn Any>>) -> Self {
unimplemented!();
}
pub fn where_not_in(mut self, key: &str, value: Vec<Box<dyn Any>>) -> Self {
unimplemented!();
}
pub fn or_where_not_in(mut self, key: &str, value: Vec<Box<dyn Any>>) -> Self {
unimplemented!();
}
// --------------------------------------------------------------------------
// ! Other Query Modifier methods
// --------------------------------------------------------------------------
/// Set a key and value for an insert or update query
pub fn set(mut self, key: &str, value: Box<dyn Any>) -> Self {
// @TODO figure a way to make this easier to use
@ -103,18 +210,101 @@ impl QueryBuilder {
self
}
/// Specify the database table to select from
pub fn from(mut self, table_name: &str) -> Self {
// @TODO properly escape the table name
self.state.from_string = table_name.to_string();
self
// Add a table join to the query
pub fn join(mut self, table: &str, condition: &str, join_type: JoinType) -> Self {
unimplemented!();
}
pub fn group_by(mut self, field: &str) -> Self {
unimplemented!();
}
pub fn order_by(mut self, field: &str, direction: OrderDirection) -> Self {
unimplemented!();
}
pub fn limit(mut self, limit: u32, offset: u32) -> Self {
unimplemented!();
}
// --------------------------------------------------------------------------
// ! Query Grouping Methods
// --------------------------------------------------------------------------
pub fn group_start(mut self) -> Self {
unimplemented!();
}
pub fn not_group_start(mut self) -> Self {
unimplemented!();
}
pub fn or_group_start(mut self) -> Self {
unimplemented!();
}
pub fn or_not_group_start(mut self) -> Self {
unimplemented!();
}
pub fn group_end(mut self) -> Self {
unimplemented!();
}
// --------------------------------------------------------------------------
// ! Query execution methods
// --------------------------------------------------------------------------
/// Execute the built query
pub fn get(self) -> Box<dyn Any> {
unimplemented!();
}
pub fn count_all(self, table: &str) -> u32 {
unimplemented!();
}
pub fn insert(mut self, table: &str) {
// @TODO determine query result type
unimplemented!();
}
pub fn update(mut self, table: &str) {
// @TODO determine query result type
unimplemented!();
}
pub fn delete(mut self, table: &str, where_clause: &str) {
unimplemented!();
}
// --------------------------------------------------------------------------
// ! SQL Returning Methods
// --------------------------------------------------------------------------
pub fn get_compiled_select(self) -> String {
unimplemented!();
}
pub fn get_compiled_insert(self) -> String {
unimplemented!();
}
pub fn get_compiled_update(self) -> String {
unimplemented!();
}
pub fn get_compiled_delete(self) -> String {
unimplemented!();
}
// --------------------------------------------------------------------------
// ! Miscellaneous Methods
// --------------------------------------------------------------------------
pub fn reset_query(mut self) -> Self {
unimplemented!();
}
}
#[cfg(test)]