Code Monkey home page Code Monkey logo

Comments (8)

bchavez avatar bchavez commented on August 18, 2024

Hi @fiLLLip , what NuGet version are you currently using?

from rethinkdb.driver.

fiLLLip avatar fiLLLip commented on August 18, 2024

2.2.0-beta-2

from rethinkdb.driver.

bchavez avatar bchavez commented on August 18, 2024

Could you supply the JSON protocol traces associated with the queries? It would really help debug the issue.

from rethinkdb.driver.

fiLLLip avatar fiLLLip commented on August 18, 2024

Is this what you are looking for?
image

from rethinkdb.driver.

fiLLLip avatar fiLLLip commented on August 18, 2024

I see the problem here. It's not the result that yields null, but result.Changes... result.replaced returns 1 😄 Closing this 👍

from rethinkdb.driver.

bchavez avatar bchavez commented on August 18, 2024

Hey @fiLLLip ,

I wrote a quick example:

[Test]
public void issue_20()
{
    var table = r.db(DbName).table(TableName);
    table.delete().run(conn);

    Console.WriteLine("INSERT");
    var result = table.insert(new {foo = "bar"}).runResult(conn);
    var id = result.GeneratedKeys[0];
    result.AssertInserted(1);

    Console.WriteLine("UPDATE 1 / VALUE 1");
    var value = "VALUE1";
    result = table.get(id).update(new {Target = value}).runResult(conn);
    result.Dump();

    Console.WriteLine("UPDATE 2 / VALUE 2");
    value = "VALUE2";
    var optResult = table.get(id).update(new {Target = value})
        .optArg("return_changes", true).run(conn);
    ExtensionsForTesting.Dump(optResult);
}

The full JSON trace I got back for the example above is:

INSERT
TRACE JSON Send: Token: 4, JSON: [1,[56,[[15,[[14,["query"]],"test"]],{"foo":"bar"}]],{}]
TRACE JSON Recv: Token: 4, JSON: {"t":1,"r":[{"deleted":0,"errors":0,"generated_keys":["d6180360-e9b6-4403-be3b-234af9458fe0"],"inserted":1,"replaced":0,"skipped":0,"unchanged":0}]}
UPDATE 1 / VALUE 1
TRACE JSON Send: Token: 5, JSON: [1,[53,[[16,[[15,[[14,["query"]],"test"]],"d6180360-e9b6-4403-be3b-234af9458fe0"]],{"Target":"VALUE1"}]],{}]
TRACE JSON Recv: Token: 5, JSON: {"t":1,"r":[{"deleted":0,"errors":0,"inserted":0,"replaced":1,"skipped":0,"unchanged":0}]}
{
  "generated_keys": null,
  "Inserted": 0,
  "Replaced": 1,
  "Unchanged": 0,
  "Errors": 0,
  "first_error": null,
  "Deleted": 0,
  "Skipped": 0,
  "Warnings": null,
  "Changes": null,
  "Ready": null,
  "dbs_created": 0,
  "dbs_dropped": 0,
  "tables_created": 0,
  "tables_dropped": 0
}
UPDATE 2 / VALUE 2
TRACE JSON Send: Token: 6, JSON: [1,[53,[[16,[[15,[[14,["query"]],"test"]],"d6180360-e9b6-4403-be3b-234af9458fe0"]],{"Target":"VALUE2"}],{"return_changes":true}],{}]
TRACE JSON Recv: Token: 6, JSON: {"t":1,"r":[{"changes":[{"new_val":{"Target":"VALUE2","foo":"bar","id":"d6180360-e9b6-4403-be3b-234af9458fe0"},"old_val":{"Target":"VALUE1","foo":"bar","id":"d6180360-e9b6-4403-be3b-234af9458fe0"}}],"deleted":0,"errors":0,"inserted":0,"replaced":1,"skipped":0,"unchanged":0}]}
{
  "changes": [
    {
      "new_val": {
        "Target": "VALUE2",
        "foo": "bar",
        "id": "d6180360-e9b6-4403-be3b-234af9458fe0"
      },
      "old_val": {
        "Target": "VALUE1",
        "foo": "bar",
        "id": "d6180360-e9b6-4403-be3b-234af9458fe0"
      }
    }
  ],
  "deleted": 0,
  "errors": 0,
  "inserted": 0,
  "replaced": 1,
  "skipped": 0,
  "unchanged": 0
}

Query 1

UPDATE 1 query:

    result = table.get(id).update(new {Target = value}).runResult(conn);

we got back a response:

 {"t":1,"r":[{"deleted":0,"errors":0,"inserted":0,"replaced":1,"skipped":0,"unchanged":0}]}

There is no Changes key to parse, so it's null in Result.

Query 2

UPDATE 2 query:

var optResult = table.get(id).update(new {Target = value})
        .optArg("return_changes", true).run(conn);
{"t":1,"r":[{"changes":[{"new_val":{"Target":"VALUE2","foo":"bar","id":"d6180360-e9b6-4403-be3b-234af9458fe0"},"old_val":{"Target":"VALUE1","foo":"bar","id":"d6180360-e9b6-4403-be3b-234af9458fe0"}}],"deleted":0,"errors":0,"inserted":0,"replaced":1,"skipped":0,"unchanged":0}]}

Now there is a Changes key to parse and populate Result.Changes. I think this is the expected behavior? Do you think there's a better way to handle this?

from rethinkdb.driver.

bchavez avatar bchavez commented on August 18, 2024

Okay, great! Glad you found the problem :) 👍

from rethinkdb.driver.

fiLLLip avatar fiLLLip commented on August 18, 2024

I obviously didn't need the changes, but just an indication that something changed! Thanks for the write up 😄

from rethinkdb.driver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.