[ckan-changes] [ckan/ckan] 06e731: [#1830] datastore_search accepts multiple filters ...

GitHub noreply at github.com
Thu Jul 3 20:20:16 UTC 2014


  Branch: refs/heads/1830-querying-multiple-values-on-the-datastore
  Home:   https://github.com/ckan/ckan
  Commit: 06e731a974263261920b51d528e8f0520962ad49
      https://github.com/ckan/ckan/commit/06e731a974263261920b51d528e8f0520962ad49
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-07-03 (Thu, 03 Jul 2014)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/interfaces.py
    M ckanext/datastore/plugin.py
    M ckanext/datastore/tests/test_search.py

  Log Message:
  -----------
  [#1830] datastore_search accepts multiple filters values as array

With this patch, if you query the datastore_search with filters:

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

It'll return the rows that have `country IN ("Brazil", "Argentina")`. I had to
change the `datastore_search` extension point on `IDatastore` because I needed
the fields' types. I needed the fields' types because the Datastore accept
fields with array type (e.g. `_text`). When filtering a field that has an array
type, I want to query literally.

In the sample query above, the Datastore can create two different queries,
depending on the type of the `country` field. If it's not an array type, it'll
do as I described above, querying `country IN ("Brazil", "Argentina")`. If it's
of an array type, it'll query literally `country = ["Brazil", "Argentina"]`.


  Commit: 4827d4603d7e91bc6b865c0a93df8d0751e962ae
      https://github.com/ckan/ckan/commit/4827d4603d7e91bc6b865c0a93df8d0751e962ae
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-07-03 (Thu, 03 Jul 2014)

  Changed paths:
    M ckanext/datastore/db.py

  Log Message:
  -----------
  [#1830] Keep the fields' order


  Commit: 8266afc881f87836744bbe1c7cd291425c905ec2
      https://github.com/ckan/ckan/commit/8266afc881f87836744bbe1c7cd291425c905ec2
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-07-03 (Thu, 03 Jul 2014)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/interfaces.py
    M ckanext/datastore/plugin.py

  Log Message:
  -----------
  [#1830] IDatastore.datastore_delete() receives fields_types

This is to keep it consistent with .datastore_search(), and make the code
started in d3761f8 work.


  Commit: b46b1af5ea80eed3691e46007998b5b218ff852b
      https://github.com/ckan/ckan/commit/b46b1af5ea80eed3691e46007998b5b218ff852b
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2014-07-03 (Thu, 03 Jul 2014)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/interfaces.py
    M ckanext/datastore/plugin.py

  Log Message:
  -----------
  [#1830] IDatastore.datastore_validate() receives fields_types

This is to keep it consistent with .datastore_search(), and make the code
started in d3761f8 work.


Compare: https://github.com/ckan/ckan/compare/baeefdbdfecf...b46b1af5ea80


More information about the ckan-changes mailing list