Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ use crate::main_module::model::data::data_object::DataObject;
pub mod main_module;

fn main() {
let new_obj = DataObject::new("name", "Oleg");
println!("{:?}", new_obj);
let new_obj = DataObject::new("name", "Oleg");
println!("{:?}", new_obj);
}
10 changes: 5 additions & 5 deletions src/main_module/controller/create_table_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
use crate::main_module::model::data::data_handler::DataHandler;

pub struct CreateTableHandler {
data_handler: DataHandler,
data_handler: DataHandler,
}

impl CreateTableHandler {
pub fn new() -> Self {
let data_handler = DataHandler::new();
pub fn new() -> Self {
let data_handler = DataHandler::new();

CreateTableHandler { data_handler }
}
CreateTableHandler { data_handler }
}
}
24 changes: 12 additions & 12 deletions src/main_module/model/data/data_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ use std::collections::{HashMap, HashSet};
use crate::main_module::model::data::table::Table;

pub struct DataHandler {
tables: HashMap<String, Table>,
tables: HashMap<String, Table>,
}

impl DataHandler {
pub fn new() -> Self {
DataHandler {
tables: HashMap::new(),
}
}
pub fn new() -> Self {
DataHandler {
tables: HashMap::new(),
}
}

pub fn create_new_table(str: &str, set: HashSet<String>) {
todo!()
}
pub fn create_new_table(str: &str, set: HashSet<String>) {
todo!()
}

pub fn insert_into_table() {
todo!()
}
pub fn insert_into_table() {
todo!()
}
}
16 changes: 8 additions & 8 deletions src/main_module/model/data/data_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@

#[derive(Debug)]
pub struct DataObject {
field_name: String,
value: String,
field_name: String,
value: String,
}

impl DataObject {
pub fn new(field_name: &str, field_value: &str) -> Self {
DataObject {
field_name: String::from(field_name),
value: String::from(field_value),
}
}
pub fn new(field_name: &str, field_value: &str) -> Self {
DataObject {
field_name: String::from(field_name),
value: String::from(field_value),
}
}
}
132 changes: 66 additions & 66 deletions src/main_module/model/data/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,73 +27,73 @@ use std::collections::{HashMap, HashSet};
use crate::main_module::model::data::data_object::DataObject;

pub struct Table {
error_id: String,
error_arg: String,
error_rws: String,
column_names: HashSet<String>,
rows: HashMap<String, Vec<DataObject>>,
error_id: String,
error_arg: String,
error_rws: String,
column_names: HashSet<String>,
rows: HashMap<String, Vec<DataObject>>,
}

impl Table {
pub fn new() -> Self {
Table {
error_id: String::from("[ERROR] [Incorrect ID]"),
error_arg: String::from("[ERROR] [Incorrect rows in insert data package"),
error_rws: String::from("[ERROR] [Trying to reach an empty row]"),
column_names: HashSet::new(),
rows: HashMap::new(),
}
}

fn generate_unique_id() {
todo!()
}

fn verify_id() {
todo!()
}

fn verify_field() {
todo!()
}

fn verify_rows() {
todo!()
}

fn verify_column_names_correct() {
todo!()
}

fn verify_id_and_field() {
todo!()
}

fn verify_id_and_columns() {
todo!()
}

pub fn row_is_empty() {
todo!()
}

pub fn get_field_value() {
todo!()
}

pub fn add_row() {
todo!()
}

pub fn return_row() {
todo!()
}

pub fn remove_row() {
todo!()
}

pub fn update_row_field_values() {
todo!()
}
pub fn new() -> Self {
Table {
error_id: String::from("[ERROR] [Incorrect ID]"),
error_arg: String::from("[ERROR] [Incorrect rows in insert data package"),
error_rws: String::from("[ERROR] [Trying to reach an empty row]"),
column_names: HashSet::new(),
rows: HashMap::new(),
}
}

fn generate_unique_id() {
todo!()
}

fn verify_id() {
todo!()
}

fn verify_field() {
todo!()
}

fn verify_rows() {
todo!()
}

fn verify_column_names_correct() {
todo!()
}

fn verify_id_and_field() {
todo!()
}

fn verify_id_and_columns() {
todo!()
}

pub fn row_is_empty() {
todo!()
}

pub fn get_field_value() {
todo!()
}

pub fn add_row() {
todo!()
}

pub fn return_row() {
todo!()
}

pub fn remove_row() {
todo!()
}

pub fn update_row_field_values() {
todo!()
}
}
60 changes: 30 additions & 30 deletions src/main_module/model/data/table_row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,43 @@
use crate::main_module::model::data::data_object::DataObject;

pub struct TableRow {
incorrect_field_name: String,
fields: Vec<DataObject>,
incorrect_field_name: String,
fields: Vec<DataObject>,
}

impl TableRow {
pub fn new(fields: Vec<DataObject>) -> Self {
TableRow {
incorrect_field_name: String::from("[ERROR] [Incorrect field name]"),
fields,
}
}
pub fn new(fields: Vec<DataObject>) -> Self {
TableRow {
incorrect_field_name: String::from("[ERROR] [Incorrect field name]"),
fields,
}
}

pub fn add_field(data_object: DataObject) {
todo!()
}
pub fn add_field(data_object: DataObject) {
todo!()
}

pub fn insert_field(data_object: DataObject) {
todo!()
}
pub fn insert_field(data_object: DataObject) {
todo!()
}

pub fn remove_field(field: String) {
todo!()
}
pub fn remove_field(field: String) {
todo!()
}

pub fn remove_field_value(field: String) {
todo!()
}
pub fn remove_field_value(field: String) {
todo!()
}

pub fn get_field_data_obj(field: String) {
todo!()
}
pub fn get_field_data_obj(field: String) {
todo!()
}

pub fn replace_existing_obj_value(current: DataObject, new: DataObject) {
todo!()
}
pub fn replace_existing_obj_value(current: DataObject, new: DataObject) {
todo!()
}

fn find_data_obj(field: String) {
todo!()
}
}
fn find_data_obj(field: String) {
todo!()
}
}
22 changes: 11 additions & 11 deletions src/main_module/model/queries/commands/create_table_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ use crate::main_module::model::queries::commands::querry_command::QueryCommand;
pub struct CreateTableCommand {}

impl QueryCommand for CreateTableCommand {
fn execute_command(command_line: String) {
let binding = command_line.replace("\\);", "");
let binding = binding.split(" \\(");
let mut command_addr = binding;
fn execute_command(command_line: String) {
let binding = command_line.replace("\\);", "");
let binding = binding.split(" \\(");
let mut command_addr = binding;

let table_name = command_addr.next().unwrap();
let column_name = command_addr.next().unwrap();
let mut column_names: HashSet<String> = HashSet::new();
column_names.insert(column_name.to_string());
let temp: HashSet<String> = HashSet::new();
let table_name = command_addr.next().unwrap();
let column_name = command_addr.next().unwrap();
let mut column_names: HashSet<String> = HashSet::new();
column_names.insert(column_name.to_string());
let temp: HashSet<String> = HashSet::new();

DataHandler::create_new_table(table_name, temp);
}
DataHandler::create_new_table(table_name, temp);
}
}
6 changes: 3 additions & 3 deletions src/main_module/model/queries/commands/insert_into_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::main_module::model::queries::commands::querry_command::QueryCommand;
pub struct InsertIntoCommand {}

impl QueryCommand for InsertIntoCommand {
fn execute_command(command_line: String) {
todo!()
}
fn execute_command(command_line: String) {
todo!()
}
}
2 changes: 1 addition & 1 deletion src/main_module/model/queries/commands/querry_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
*/

pub trait QueryCommand {
fn execute_command(command_line: String);
fn execute_command(command_line: String);
}
2 changes: 1 addition & 1 deletion src/main_module/model/queries/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
use crate::main_module::model::queries::query_element::QueryElement;

pub struct Query {
query_elements: Vec<QueryElement>,
query_elements: Vec<QueryElement>,
}
2 changes: 1 addition & 1 deletion src/main_module/model/queries/query_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
*/

pub struct QueryElement {
query_composition: Vec<QueryElement>,
query_composition: Vec<QueryElement>,
}
10 changes: 5 additions & 5 deletions src/main_module/model/queries/query_keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
*/

pub enum QueryKeyword {
CREATE_TABLE,
SELECT,
UPDATE,
DELETE,
INSERT_INTO,
CREATE_TABLE,
SELECT,
UPDATE,
DELETE,
INSERT_INTO,
}