keenlabs / KeenClient-Python

Official Python client for the Keen IO API. Build analytics features directly into your Python apps.
https://keen.io/docs
MIT License
133 stars 58 forks source link

Saved Query partial update of nested array #128

Open masojus opened 7 years ago

masojus commented 7 years ago

Investigate what happens when trying to do an update of a Saved/Cached Query definition such that an element in a nested array is the target of the update. Filters, Funnel Steps and Group By parameters come to mind.

I suspect that right now this works if your target update is the entire array, and you set an entire new list as Filters or Funnel Steps or Group By params. Right now I think when _deep_update() sees the list as something that's not a Mapping it'll stop there and set the entire list as the new property.

Additionally, you really probably just want to change a single property in a particular element in the list, so maybe only the filter op of the 2nd of 3 filters needs to change from gt to gte so how to express that? If this were a realistic scenario, one would send something like this as the conceptual partial update:

{
  "query": {
    "filters": [
      None,
      {
        "operator": "gte",
      }
      None,
    ]
  }
}

Really, this sort of nested complex update is probably A) not common, B) even less likely to happen in a scenario also involving remote collaborative changes to the same query, which is the source of part of the problem solved by partial updates--to not lose remote changes, and therefore C) better handled by just re-creating the query definition from scratch (which avoids dealing with disallowed properties being sent, like last_modified_date and friends).

Thoughts?