ckan/ckan — pull request #1830 by vitorbaptista (2014-07-03 20:03:01+00:00)
Title: Allow querying multiple filters values on the same field on the Datastore

The filters created for #1251 needs the datastore to allow querying multiple filters as:

```json
{
"filters": {
"country": ["Brazil", "Argentina"]
}
}
```

The DataStore should turn that into a query like `... WHERE country IN ("Brazil", "Argentina") ...`. We monkey patched the DataStore on #1251 at d5593d7 to add this feature, but with the new code merged in #1725 that doesn't work anymore.

I was merging #1725 on #1251 and realized that there's a test to guarantee that you can filter an array type column passing an array. This makes things a bit more complicated.

Given my sample query I wrote above, we can have two cases. If the `country` column is of an array type (e.g. `_text`), then this query should create `... WHERE country = ["Brazil", "Argentina"] ...` (i.e. literally test that the column is equal to the array). But if the `country` column isn't of an array type (e.g. `text`), then the query should be `... WHERE country IN ("Brazil", "Argentina") ...`.

Doing that isn't too difficult, but we need the column types. Unfortunately, on #1725, I only passed the column names to the extensions. So I could either replicate the datastore's db.py `_get_fields()` code in `DatastorePlugin`, and get the fields' types, or we could change the IDatastore interface to pass the columns names and types, instead of just the names.

As that issue was just merged, and there're no extensions using it yet (except maybe from @aliceh's), I'd rather change IDatastore and pass the columns names *AND* types.

What do you think, @joetsoi @amercader ?