Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse single array as sequence when response type is SUCCESS_ATOM #69

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
18 changes: 17 additions & 1 deletion reql/src/cmd/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,23 @@ where
let (response_type, resp) = conn.request(&payload, noreply).await?;
trace!("yielding response; token: {}", conn.token);
match response_type {
ResponseType::SuccessAtom | ResponseType::SuccessSequence | ResponseType::ServerInfo => {
ResponseType::SuccessAtom => {
// If response is array then will try to flat it
// [[1, 2, 3]] => [1, 2, 3]
let atom_val = if let Value::Array(arr) = resp.r {
match &arr[0] {
Value::Array(inner_arr) => Value::Array(inner_arr.clone()),
_ => Value::Array(arr),
}
} else {
resp.r
};
for val in serde_json::from_value::<Vec<T>>(atom_val)? {
yield val;
}
break;
},
ResponseType::SuccessSequence | ResponseType::ServerInfo => {
for val in serde_json::from_value::<Vec<T>>(resp.r)? {
yield val;
}
Expand Down