Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/224.canada.changes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The error message for duplicate DataStore column names will now display which supplied column names are the duplicated ones.
12 changes: 10 additions & 2 deletions ckanext/datastore/backend/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
import hashlib
import json
import decimal
from collections import OrderedDict
# (canada fork only): show duplicate keys
# TODO: upstrea contrib??
from collections import OrderedDict, Counter

from urllib.parse import (
urlencode, urlunparse, parse_qsl, urlparse
Expand Down Expand Up @@ -1251,8 +1253,14 @@ def create_table(
# Check for duplicate fields
unique_fields = {f['id'] for f in supplied_fields}
if not len(unique_fields) == len(supplied_fields):
# (canada fork only): show duplicate keys
# TODO: upstrea contrib??
field_id_counts = Counter([f['id'] for f in supplied_fields])
duplicate_field_ids = [fid for fid, count in
field_id_counts.items() if count > 1]
raise ValidationError({
'field': ['Duplicate column names are not supported']
'field': ['Duplicate column names are not supported: {}'.format(
', '.join(duplicate_field_ids))]
})

if records:
Expand Down
Loading