librethinkdbxx icon indicating copy to clipboard operation
librethinkdbxx copied to clipboard

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

Open mflerackers opened this issue 9 years ago • 2 comments

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());
  }
});

mflerackers avatar Mar 23 '16 05:03 mflerackers

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.

AtnNn avatar Mar 30 '16 15:03 AtnNn

It just gives zero results, no error was thrown

mflerackers avatar Mar 31 '16 08:03 mflerackers