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

Conversation

vettich
Copy link

@vettich vettich commented Jan 2, 2023

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
Copy link
Author

vettich commented Jan 2, 2023

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