{"action":"opened","issue":{"url":"https://api.github.com/repos/couchbase/couchbase-lite-core/issues/630","repository_url":"https://api.github.com/repos/couchbase/couchbase-lite-core","labels_url":"https://api.github.com/repos/couchbase/couchbase-lite-core/issues/630/labels{/name}","comments_url":"https://api.github.com/repos/couchbase/couchbase-lite-core/issues/630/comments","events_url":"https://api.github.com/repos/couchbase/couchbase-lite-core/issues/630/events","html_url":"https://github.com/couchbase/couchbase-lite-core/issues/630","id":390795911,"node_id":"MDU6SXNzdWUzOTA3OTU5MTE=","number":630,"title":"Add \"CAST\" query operator","user":{"login":"snej","id":43241,"node_id":"MDQ6VXNlcjQzMjQx","avatar_url":"https://avatars2.githubusercontent.com/u/43241?v=4","gravatar_id":"","url":"https://api.github.com/users/snej","html_url":"https://github.com/snej","followers_url":"https://api.github.com/users/snej/followers","following_url":"https://api.github.com/users/snej/following{/other_user}","gists_url":"https://api.github.com/users/snej/gists{/gist_id}","starred_url":"https://api.github.com/users/snej/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snej/subscriptions","organizations_url":"https://api.github.com/users/snej/orgs","repos_url":"https://api.github.com/users/snej/repos","events_url":"https://api.github.com/users/snej/events{/privacy}","received_events_url":"https://api.github.com/users/snej/received_events","type":"User","site_admin":false},"labels":[{"id":432469194,"node_id":"MDU6TGFiZWw0MzI0NjkxOTQ=","url":"https://api.github.com/repos/couchbase/couchbase-lite-core/labels/enhancement%20:open_mouth:","name":"enhancement :open_mouth:","color":"84b6eb","default":false},{"id":575651869,"node_id":"MDU6TGFiZWw1NzU2NTE4Njk=","url":"https://api.github.com/repos/couchbase/couchbase-lite-core/labels/f/query","name":"f/query","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-13T18:05:42Z","updated_at":"2018-12-13T18:05:42Z","closed_at":null,"author_association":"MEMBER","body":"We should have a query operator to cast a value to a type (at least to string or numeric.) There are situations where you need to convert two values to the same type to compare them, for example (as in [this forum post](https://forums.couchbase.com/t/property-conversion-from-string-to-int-vice-versa/19464)) a join where one property is a number and the other a numeric string.\r\n\r\nThe [SQLite syntax](https://sqlite.org/lang_expr.html#castexpr) is `CAST(expr AS type)`, where `type` is a SQL column type, as in [this list](\r\nhttps://sqlite.org/datatype3.html#affinity_name_examples). The resulting affinity will be text, numeric, integer, real, or blob.\r\n\r\nThere are some workarounds, that use operators that typecast their operands:\r\n* `(x + 0)` will convert x to a number\r\n* `(x || '')` will convert x to a string"}}
{"actor":{"display_login":"snej"}}