mirror of
https://github.com/eliasrenman/r-database.git
synced 2026-03-16 20:46:08 +01:00
chore: replaced HashMap with Map
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
use serde_json::Value;
|
use serde_json::{Map, Value};
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
pub type Row = HashMap<String, Value>;
|
pub type Row = Map<String, Value>;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ impl SelectProcessor {
|
|||||||
table_name: &String,
|
table_name: &String,
|
||||||
row: &Row,
|
row: &Row,
|
||||||
select: Vec<&str>,
|
select: Vec<&str>,
|
||||||
) -> HashMap<String, Value> {
|
) -> Map<String, Value> {
|
||||||
let asd = SelectProcessor::parse_node(select);
|
let asd = SelectProcessor::parse_node(select);
|
||||||
println!("Debugging parsed selector {asd}");
|
println!("Debugging parsed selector {asd}");
|
||||||
SelectProcessor::recursive_traverse_resolver(database, table_name, row, &asd)
|
SelectProcessor::recursive_traverse_resolver(database, table_name, row, &asd)
|
||||||
@@ -27,20 +27,20 @@ impl SelectProcessor {
|
|||||||
table_name: &String,
|
table_name: &String,
|
||||||
row: &Row,
|
row: &Row,
|
||||||
selector: &Value,
|
selector: &Value,
|
||||||
) -> HashMap<String, Value> {
|
) -> Map<String, Value> {
|
||||||
let object = selector.as_object().unwrap();
|
let object = selector.as_object().unwrap();
|
||||||
let mut output: HashMap<String, Value> = HashMap::new();
|
let mut output: Map<String, Value> = Map::new();
|
||||||
for (key, value) in object.into_iter() {
|
for (key, value) in object.into_iter() {
|
||||||
if value.is_object() {
|
if value.is_object() {
|
||||||
let relation_rows: Value =
|
let relation_rows: Value =
|
||||||
SelectProcessor::resolve_relation(database, table_name, row, key);
|
SelectProcessor::resolve_relation(database, table_name, row, key);
|
||||||
|
|
||||||
if relation_rows.is_array() {
|
if relation_rows.is_array() {
|
||||||
let mut row_vec: Vec<HashMap<String, Value>> = vec![];
|
let mut row_vec: Vec<Map<String, Value>> = vec![];
|
||||||
for row in relation_rows.as_array().unwrap() {
|
for row in relation_rows.as_array().unwrap() {
|
||||||
let asd = Row::from(row.as_object().unwrap());
|
let asd = row.as_object().unwrap();
|
||||||
let parsed_row = SelectProcessor::recursive_traverse_resolver(
|
let parsed_row = SelectProcessor::recursive_traverse_resolver(
|
||||||
database, table_name, &(row.as_object().unwrap()), &value,
|
database, table_name, &asd, &value,
|
||||||
);
|
);
|
||||||
row_vec.push(parsed_row);
|
row_vec.push(parsed_row);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
macro_rules! row {
|
macro_rules! row {
|
||||||
($( $key: expr => $val: expr ),*) => {{
|
($( $key: expr => $val: expr ),*) => {{
|
||||||
let mut map: crate::database::row::Row = ::std::collections::HashMap::new();
|
let mut map: crate::database::row::Row = serde_json::Map::new();
|
||||||
$( map.insert($key.to_string(), serde_json::to_value($val).unwrap()); )*
|
$( map.insert($key.to_string(), serde_json::to_value($val).unwrap()); )*
|
||||||
map
|
map
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user