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

Lightblue skips timezone transformation in case of nested JSON update #818

Open
kusha opened this issue Feb 2, 2018 · 1 comment
Open

Comments

@kusha
Copy link

kusha commented Feb 2, 2018

For example, I have the following data structure (tested with the MongoDB controller):

{
  "key1": {
    "key2": "... any timestamp ..."
  }
}

... and LightBlue returns -5 timezone (default at the server, non-UTC) in find queries by default.

Correct behavior

If I'm updating the item with the following query and UTC time:

{
  "objectType": "...",
  "version": "...",
  "query": {
    ... select the item above ...
  },
  "update": {
    "$set": {
      "key1.key2": "20171214T00:19:40.000-0000"
    }
  },
  "projection": [
    {
      "field": "key1",
      "include": true,
      "recursive": true
    }
  ]
}

I'm receiving the time transformed to the -5 timezone (non-UTC, as in the find query) in the projection:

{
  "_id": "... any id ...",
  "key1": {
    "key2": "20171213T19:19:40.000-0500"
  }
}

Incorrect behavior

If I'm updating the time value with the following request (please, note the nested JSON):

{
  "objectType": "...",
  "version": "...",
  "query": {
    ... select the item above ...
  },
  "update": {
    "$set": {
      "key1": {
        "key2": "20171214T00:19:40.000-0000"
      }
    }
  },
  "projection": [
    {
      "field": "key1",
      "include": true,
      "recursive": true
    }
  ]
}

I'm receiving the UTC timezone in the projection as provided in the query (UTC, without any transformation):

{
  "_id": "... any id ...",
  "key1": {
    "key2": "20171214T00:19:40.000-0000"
  }
}

Can you, please, confirm, that such behavior isn't expected?
In some cases, I'm updating nested structures and it isn't a good idea to pop the time leafs in the query. How we can fix or workaround that?

@alechenninger
Copy link
Contributor

As far as I can tell there is no documented contracts around timestamps' offsets that lightblue returns. I agree it is surprising that it is not consistent, but for this reason I would recommend clients do not couple to any specific time offset that lightblue returns and remain agnostic to whether lightblue returns the same as the client, UTC, or system zone, even within the same response.

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