Ticket #1054 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

Ordering of resources

Reported by: dread Owned by: kindly
Priority: major Milestone: ckan-v1.4-sprint-4
Component: ckan Keywords:
Cc: Repository: ckan
Theme: none

Description

Changing an old resource and creating a new resource on the end results in the old resource moving to the end in the ordering.

This breaks tests:

  • (ckanext-dgu) ckanext/dgu/tests/ons/test_ons_loader.py:TestOnsLoadBasic.test_fields
  • (ckanext-importlib) ckanext/importlib/tests/test_loader.py:TestLoaderInsertingResources.test_0_reload

You can make a ckan test break with this patch:

diff -r e6643cf1324c ckan/tests/models/test_resource.py
--- a/ckan/tests/models/test_resource.py        Wed Mar 23 13:25:52 2011 +0000
+++ b/ckan/tests/models/test_resource.py        Wed Mar 23 19:22:35 2011 +0000
@@ -297,6 +297,8 @@
                'url':self.urls[1], 'format':u'OTHER FORMAT',
                'description':self.description, 'hash':self.hash,
                'id':original_res_ids[2]},
+            { #new
+                'url':'new'},
            ]
        pkg.update_resources(res_dicts)
        model.repo.commit_and_remove()

There seems to be a problem with vdm creating a replacement Resource for the old resource - because it has a duplicate position it is put to the end by the SQLAlchemy ordering_list function.

Change History

comment:1 Changed 3 years ago by dread

I've added some tests in the branch: defect-1054-resource-order

comment:2 Changed 3 years ago by dread

I've put in a potential fix for this into the branch - do take a look and see what you think.

comment:3 Changed 3 years ago by dread

  • Milestone set to ckan-v1.4-sprint-4

comment:4 Changed 3 years ago by kindly

Looks great. Had a look and changed a minor thing because I was not confident with the handling of the null values. I made a fake resource and did an asdict on that to make the identity.

Part of my patch I reverted as I mucked up my version of the vdm, so it was not needed.

comment:5 Changed 3 years ago by dread

  • Status changed from new to closed
  • Resolution set to fixed

This branch is now merged.

Note: See TracTickets for help on using tickets.