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

$reql_type$ not converted when the result is an array. #65

Closed
oliverjanik opened this issue May 25, 2016 · 2 comments
Closed

$reql_type$ not converted when the result is an array. #65

oliverjanik opened this issue May 25, 2016 · 2 comments
Labels

Comments

@oliverjanik
Copy link

oliverjanik commented May 25, 2016

This is a continuation from #39.

Using the latest stable 2.3.3 the second pass for JObject is performed when I do:

Table().Get().RunAtomAsync<JObject>(Conn)

I get correct display like this:

{
  "_createdBy": "oliver",
  "_storedAt": "2016-05-25T01:46:20.436+00:00",
  "id": "3ef139be-5f85-490d-b9bc-402c42945290",
  "test": "hello!"
}

However when I ask for an IEnumerable of JObjects the conversion is not performed:

Table().RunAtomAsync<IEnumerable<JObject>>(Conn)

This returns:

[
  {
    "_createdBy": "oliver",
    "_storedAt": {
      "$reql_type$": "TIME",
      "epoch_time": 1464140780.436,
      "timezone": "+00:00"
    },
    "id": "3ef139be-5f85-490d-b9bc-402c42945290",
    "test": "hello!"
  },
  ...
]

It looks like JObject is special cased somewhere. I'm wandering what happens If I ask for IDictionary<string, JObject>. I've tried plain object and the second pass conversion does not happen either.

I'm using RethinkDB fully dynamically. I don't have classes for my data. That's the main reason I picked RethinkDB. My queries are composed of ReqlExpr on the fly. Is this a use case you want to fully support in this driver? Sorry for creating headaches for you.

@bchavez
Copy link
Owner

bchavez commented May 25, 2016

In RunAtomAsync<T>, T is IEumerable. IEnumerable is not JToken type. So, it won't be converted using the 2nd-pass converter. You'll need to ask for T as JArray (RunAtomAsync<JArray>) which derives from JToken and pick off the JObjects from within the JArray.

🌗 🌗 _"Uh huh, you know what it is. Black and yellow..."_

@oliverjanik
Copy link
Author

Works beautifully. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants