{"action":"created","issue":{"url":"https://api.github.com/repos/numberoverzero/bloop/issues/73","repository_url":"https://api.github.com/repos/numberoverzero/bloop","labels_url":"https://api.github.com/repos/numberoverzero/bloop/issues/73/labels{/name}","comments_url":"https://api.github.com/repos/numberoverzero/bloop/issues/73/comments","events_url":"https://api.github.com/repos/numberoverzero/bloop/issues/73/events","html_url":"https://github.com/numberoverzero/bloop/issues/73","id":186170263,"number":73,"title":"Question: What is the best way to filter list types?","user":{"login":"jasonlockporcelane","id":18404124,"avatar_url":"https://avatars.githubusercontent.com/u/18404124?v=3","gravatar_id":"","url":"https://api.github.com/users/jasonlockporcelane","html_url":"https://github.com/jasonlockporcelane","followers_url":"https://api.github.com/users/jasonlockporcelane/followers","following_url":"https://api.github.com/users/jasonlockporcelane/following{/other_user}","gists_url":"https://api.github.com/users/jasonlockporcelane/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonlockporcelane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonlockporcelane/subscriptions","organizations_url":"https://api.github.com/users/jasonlockporcelane/orgs","repos_url":"https://api.github.com/users/jasonlockporcelane/repos","events_url":"https://api.github.com/users/jasonlockporcelane/events{/privacy}","received_events_url":"https://api.github.com/users/jasonlockporcelane/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-30T22:42:08Z","updated_at":"2016-10-30T23:35:13Z","closed_at":null,"body":"Hello,\r\nI'm trying to filter on a models column that is a list type. The model looks like [this](https://gist.github.com/jasonlockporcelane/610d35d0a6a56929ca5d17fb05854e34) and the filter looks something like this: \r\n```\r\ndentist_shifts_query = engine.scan(DentistShift).filter(lte_time_window & gte_time_window)\r\ndentist_shifts_query = dentist_shifts_query.filter(DentistShift.cities.contains(address.city))\r\n```\r\nbut that yields no results. I've tried this too: \r\n```\r\ndentist_shifts_query = engine.scan(DentistShift).filter(lte_time_window & gte_time_window)\r\ndentist_shifts_query = dentist_shifts_query.filter(DentistShift.cities[0].contains(address.city))\r\n```\r\nthis returns only shifts with cities at that index. I'm wondering, is there a better way to filter on a models column that is a list. \r\n\r\nPlease let me know if you need anymore info and thank you for your time!"},"comment":{"url":"https://api.github.com/repos/numberoverzero/bloop/issues/comments/257188616","html_url":"https://github.com/numberoverzero/bloop/issues/73#issuecomment-257188616","issue_url":"https://api.github.com/repos/numberoverzero/bloop/issues/73","id":257188616,"user":{"login":"numberoverzero","id":1223809,"avatar_url":"https://avatars.githubusercontent.com/u/1223809?v=3","gravatar_id":"","url":"https://api.github.com/users/numberoverzero","html_url":"https://github.com/numberoverzero","followers_url":"https://api.github.com/users/numberoverzero/followers","following_url":"https://api.github.com/users/numberoverzero/following{/other_user}","gists_url":"https://api.github.com/users/numberoverzero/gists{/gist_id}","starred_url":"https://api.github.com/users/numberoverzero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/numberoverzero/subscriptions","organizations_url":"https://api.github.com/users/numberoverzero/orgs","repos_url":"https://api.github.com/users/numberoverzero/repos","events_url":"https://api.github.com/users/numberoverzero/events{/privacy}","received_events_url":"https://api.github.com/users/numberoverzero/received_events","type":"User","site_admin":false},"created_at":"2016-10-30T23:35:13Z","updated_at":"2016-10-30T23:35:13Z","body":"On the list filter issue, I have a pretty good guess.  I tried using `cities.contains(\"boston\")` and hit a ValidationException:\r\n\r\n```python\r\nbotocore.exceptions.ClientError: An error occurred (ValidationException) when calling the Scan operation: ExpressionAttributeValues contains invalid value: One or more parameter values were invalid: Input collection [b, n, o, o, s, t] contains duplicates. for key :v1\r\n```\r\n\r\nWalking this through, it's an annoying coincidence (again) that strings are iterable.  The column's type is `List(String)`; if you dumped `[\"foo\", \"bar\"]` through it, each value in the input (the whole list) would be dumped through the list's inner type (string).  However, \"boston\" is also iterable and the type calls `String.dump()` on each letter (since it iterate the input value \"boston\").\r\n\r\n```ipython\r\nIn [1]: from bloop import List, String\r\nIn [2]: type = List(String)\r\nIn [3]: type.dynamo_dump([\"first\", \"second\"])\r\nOut[3]: [{'S': 'first'}, {'S': 'second'}]\r\nIn [4]: type.dynamo_dump(\"whoa\")\r\nOut[4]: [{'S': 'w'}, {'S': 'h'}, {'S': 'o'}, {'S': 'a'}]\r\n```"}}
{"actor":{"display_login":"numberoverzero"}}