[ckan-changes] [ckan/ckan] 8f5f16: [#2158] Replace all resource extras on update so t...

GitHub noreply at github.com
Tue Feb 17 09:47:06 UTC 2015


  Branch: refs/heads/2158-resource-extras
  Home:   https://github.com/ckan/ckan
  Commit: 8f5f161c39b17a182e12adce3738e0ceaff4c960
      https://github.com/ckan/ckan/commit/8f5f161c39b17a182e12adce3738e0ceaff4c960
  Author: amercader <amercadero at gmail.com>
  Date:   2015-02-17 (Tue, 17 Feb 2015)

  Changed paths:
    M ckan/lib/dictization/model_save.py

  Log Message:
  -----------
  [#2158] Replace all resource extras on update so they don't get lost

Resource `extras` were being ignored on `resource_udpate`. The rest of
the resource field got updated but no the extras.

The resource `extras` field is using a custom `JsonDictType`, and
according to SQLAlchemy documentation:

> Note that the ORM by default will not detect “mutability” on such a
> type - meaning, in-place changes to values will not be detected and
> will not be flushed. Without further steps, you instead would need to
> replace the existing value with a new one on each parent object to
> detect changes.

Replacing `obj.extras` with a new dict solves the issue

http://docs.sqlalchemy.org/en/rel_0_9/core/custom_types.html#marshal-json-strings


  Commit: d1cacbb6753e3c33ae18b6db96203848515eca0b
      https://github.com/ckan/ckan/commit/d1cacbb6753e3c33ae18b6db96203848515eca0b
  Author: amercader <amercadero at gmail.com>
  Date:   2015-02-17 (Tue, 17 Feb 2015)

  Changed paths:
    M ckan/new_tests/logic/action/test_update.py

  Log Message:
  -----------
  [#2158] Add more tests


Compare: https://github.com/ckan/ckan/compare/60465cf744fd...d1cacbb6753e


More information about the ckan-changes mailing list