Time pseudotype instead of ISO8601 when using group operator
Asked Answered
M

1

8

I'm getting started with RethinkDB and I'm having some trouble understanding what's going on with some queries I'm running.

The problem is querying objects with date time types from a NodeJS app (using the rethinkdbdash driver) which exposes a JSON API. If I query my objects individually like:

db.table('apples').max('timestamp');

I get JavaScript Dates for timestamp fields, while if I run a group by operator in the query like in:

db.table('apples').group('type').max('timestamp');

I get date time pseudotypes (I think this is the correct name) for the same timestamp fields instead. Something like:

{
  "$reql_type$": "TIME",
  "epoch_time": 1423077646.772,
  "timezone": "-07:00"
}

Is this the expected behaviour? What is the logic behind it?

I would like to return serialized iso8601 dates in my JSON and not this data type to make parsing transparent to clients.

thanks,


UPDATE This was a known issue for versions prior to 2.2.7. Fixed here.

Maziar answered 3/12, 2015 at 14:48 Comment(0)
S
2

That looks like a bug in rethinkdbdash. The server always sends times to the clients as pseudotypes (the object with the $reql_type$ field), and the clients are responsible for turning the pseudotypes into native time objects (since drivers in different languages have to do that differently). I'd open a bug at https://github.com/neumino/rethinkdbdash/issues .

I would guess the source of the bug is that group returns a GROUPED_DATA pseudotype and rethinkdbdash isn't correctly converting pseudotypes that are inside of other pseudotypes. If you run db.table('apples').group('type').max('timestamp').ungroup(), that might fix the problem for this query until the driver is patched.

Sabin answered 7/12, 2015 at 10:8 Comment(1)
Thanks for you answer @mlucy, ungrouping does indeed fix the problem in this specific case. I'll bring it up to the rethinkdbdash people. Thanks again.Maziar

© 2022 - 2024 — McMap. All rights reserved.