Skip to content

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

Open
vettich wants to merge 1 commit into
rethinkdb:mainfrom
vettich:feature/destruct_array_for_atom_response
Open

parse single array as sequence when response type is SUCCESS_ATOM#69
vettich wants to merge 1 commit into
rethinkdb:mainfrom
vettich:feature/destruct_array_for_atom_response

Conversation

@vettich

@vettich vettich commented Jan 2, 2023

Copy link
Copy Markdown

There was a problem with queries:

Simple get all items in table

let mut cur = r.table(name).run::<_, T>(conn);
let mut res: Vec<T> = vec![];
while let Some(val) = cur.try_next().await? {
    res.push(val);
}
//...

and with order_by

let mut cur = r.table(name).order_by("created_at").run::<_, T>(conn);
let mut res: Vec<T> = vec![];
while let Some(val) = cur.try_next().await? {
    res.push(val);
}
// ...

In both cases, in the while, I expect an enumeration of the elements in the table. But when I try to sort with order_by, rethinkdb returns not SUCCESS_SEQUENCE with an array of elements ([1, 2, 3, ...]), but returns SUCCESS_ATOM with an array of one element of the elements array ([[1, 2, 3, ...]]). So in the second case I had a JSON parsing error

I tried to bring this to the one expected form: to a simple array of elements [1, 2, 3, ...]

@vettich

vettich commented Jan 2, 2023

Copy link
Copy Markdown
Author

A similar implementation is used in the go library
https://github.com/rethinkdb/rethinkdb-go/blob/master/cursor.go#L692

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant