Skip to content

Commit

Permalink
fix(logic): loader;
Browse files Browse the repository at this point in the history
- Tabulator load existing fields for data dict ckan versions.
  • Loading branch information
JVickery-TBS committed Dec 9, 2024
1 parent 6587421 commit 20a33f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 39 deletions.
7 changes: 5 additions & 2 deletions ckanext/xloader/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,11 @@ def load_table(table_filepath, resource_id, mimetype='text/csv', logger=None):
existing = datastore_resource_exists(resource_id)
existing_info = None
if existing:
ds_info = p.toolkit.get_action('datastore_info')({'ignore_auth': True}, {'id': resource_id})
existing_fields = ds_info.get('fields', [])
if p.toolkit.check_ckan_version(min_version='2.10'):
ds_info = p.toolkit.get_action('datastore_info')({'ignore_auth': True}, {'id': resource_id})
existing_fields = ds_info.get('fields', [])
else:
existing_fields = existing.get('fields', [])
existing_info = dict(
(f['id'], f['info'])
for f in existing_fields if 'info' in f)
Expand Down
37 changes: 0 additions & 37 deletions ckanext/xloader/tests/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1566,11 +1566,6 @@ def test_load_with_no_strip_white(self, Session):
None, {"resource_id": resource_id, "limit": 0}
)
fields = [f for f in rec["fields"] if not f["id"].startswith("_")]
print(' ')
print('DEBUGGING::step 1')
print(' ')
print(fields)
print(' ')
for field in fields:
if "info" not in field:
field["info"] = {}
Expand All @@ -1581,38 +1576,6 @@ def test_load_with_no_strip_white(self, Session):
{"resource_id": resource_id, "force": True, "fields": fields},
)

rec = p.toolkit.get_action("datastore_search")(
None, {"resource_id": resource_id, "limit": 0}
)
fields = [f for f in rec["fields"] if not f["id"].startswith("_")]
print(' ')
print('DEBUGGING::step 2')
print(' ')
print(fields)
print(' ')

ds_info = p.toolkit.get_action('datastore_info')({'ignore_auth': True}, {'id': resource_id})
existing_fields = ds_info.get('fields', [])
existing_info = dict(
(f['id'], f['info'])
for f in existing_fields if 'info' in f)
existing_fields_by_headers = dict((f['id'], f)
for f in existing_fields)

print(' ')
print('DEBUGGING::step 3')
print(' ')
print(existing_info)
print(' ')

print(' ')
print('DEBUGGING::step 4')
print(' ')
print(existing_fields_by_headers)
print(' ')

assert False

# Load it again with new strip_extra_white
fields = loader.load_table(
csv_filepath,
Expand Down

0 comments on commit 20a33f6

Please sign in to comment.