Skip to content
This repository has been archived by the owner on Sep 28, 2021. It is now read-only.

Commit

Permalink
fix clippy and rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-dukhno committed Jan 31, 2021
1 parent c920272 commit 164fb92
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
30 changes: 21 additions & 9 deletions data/catalog/src/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,24 +258,36 @@ impl Database for InMemoryDatabase {
}
Step::RemoveFolder { name, only_if_empty } => {
match self.catalog.work_with(&name, |schema| schema.empty()) {
Some(true) if *only_if_empty == true => {
Some(true) if *only_if_empty => {
self.catalog.drop_schema(&name);
},
Some(_) if *only_if_empty == false => {
}
Some(_) if !*only_if_empty => {
let all_tables = self.catalog.work_with(&name, |schema| schema.all_tables()).unwrap();
log::debug!("tables to remove {:?}", all_tables);
self.catalog.work_with(DEFINITION_SCHEMA, |schema| {
schema.work_with(TABLES_TABLE, |table| {
let table_ids = table.select().map(|(key, value)| (key, value.unpack())).filter(|(_key, value)| {
&value[1].as_string() == name && all_tables.contains(&value[2].as_string())
}).map(|(key, _value)| key).collect();
let table_ids = table
.select()
.map(|(key, value)| (key, value.unpack()))
.filter(|(_key, value)| {
&value[1].as_string() == name
&& all_tables.contains(&value[2].as_string())
})
.map(|(key, _value)| key)
.collect();
log::debug!("table IDs {:?}", table_ids);
table.delete(table_ids);
});
schema.work_with(COLUMNS_TABLE, |table| {
let columns_ids = table.select().map(|(key, value)| (key, value.unpack())).filter(|(_key, value)| {
&value[1].as_string() == name && all_tables.contains(&value[2].as_string())
}).map(|(key, _value)| key).collect();
let columns_ids = table
.select()
.map(|(key, value)| (key, value.unpack()))
.filter(|(_key, value)| {
&value[1].as_string() == name
&& all_tables.contains(&value[2].as_string())
})
.map(|(key, _value)| key)
.collect();
log::debug!("column IDs {:?}", columns_ids);
table.delete(columns_ids);
});
Expand Down
1 change: 0 additions & 1 deletion data/catalog/src/in_memory/data_catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ impl SchemaHandle for InMemorySchemaHandle {
self.tables.iter().map(|entry| entry.key().clone()).collect()
}


fn work_with<T, F: Fn(&Self::Table) -> T>(&self, table_name: &str, operation: F) -> Option<T> {
self.tables.get(table_name).map(|table| operation(&*table))
}
Expand Down
2 changes: 1 addition & 1 deletion data/catalog/src/in_memory/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fn drop_schema_op(schema_name: &str) -> Vec<Step> {
},
Step::RemoveFolder {
name: schema_name.to_owned(),
only_if_empty: true
only_if_empty: true,
},
]
}
Expand Down
2 changes: 1 addition & 1 deletion data/catalog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ use binary::Binary;
use data_definition_operations::{ExecutionError, ExecutionOutcome, SystemOperation};
use data_manipulation_typed_tree::{DynamicTypedTree, StaticTypedTree};
use definition::{ColumnDef, FullTableName, SchemaName, TableDef};
use repr::Datum;
use std::{
fmt::{self, Debug, Formatter},
iter::FromIterator,
};
use repr::Datum;

pub use in_memory::InMemoryDatabase;

Expand Down
4 changes: 2 additions & 2 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
max_width=120
max_width = 120
license_template_path = "HEADER"
merge_imports = true
imports_granularity = "Crate"

0 comments on commit 164fb92

Please sign in to comment.