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

.changes() works, but limit(n).changes doesn't #11

Open
mflerackers opened this issue Mar 23, 2016 · 2 comments
Open

.changes() works, but limit(n).changes doesn't #11

mflerackers opened this issue Mar 23, 2016 · 2 comments

Comments

@mflerackers
Copy link

The following code correctly streams results from a changes feed

static auto handle = std::async(std::launch::async, [](){
  try {
    std::unique_ptr<RethinkDB::Connection> conn = RethinkDB::connect("172.17.10.61", 28015);
    RethinkDB::Cursor cursor = RethinkDB::table("leaderboard").changes().run(*conn);
    for (auto score = cursor.begin(); score != cursor.end(); ++score) {
      printf("%s\n", RethinkDB::write_datum(*score).c_str());
    }
  } catch (RethinkDB::Error &err) {
    printf("%s\n", err.message.c_str());
  }
});

However adding a limit (which would need an order_by, but see #10 ) gives no more results.

static auto handle = std::async(std::launch::async, [](){
  try {
    std::unique_ptr<RethinkDB::Connection> conn = RethinkDB::connect("172.17.10.61", 28015);
    RethinkDB::Cursor cursor = RethinkDB::table("leaderboard").limit(2).changes().run(*conn);
    for (auto score = cursor.begin(); score != cursor.end(); ++score) {
      printf("%s\n", RethinkDB::write_datum(*score).c_str());
    }
  } catch (RethinkDB::Error &err) {
    printf("%s\n", err.message.c_str());
  }
});
@AtnNn
Copy link
Owner

AtnNn commented Mar 30, 2016

That query is invalid and should throw an error. I got the following error when I tested your code:

Cannot get changes on the first elements of an unordered stream.

@mflerackers
Copy link
Author

It just gives zero results, no error was thrown

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

No branches or pull requests

2 participants