Fixed incorrect display of compound primary keys with foreign key references

Closes #319
This commit is contained in:
Simon Willison 2018-06-21 07:56:28 -07:00
commit 3b53eea382
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
5 changed files with 122 additions and 10 deletions

View file

@ -70,8 +70,10 @@ def path_from_row_pks(row, pks, use_rowid, quote=True):
if use_rowid:
bits = [row['rowid']]
else:
bits = [row[pk] for pk in pks]
bits = [
row[pk]["value"] if isinstance(row[pk], dict) else row[pk]
for pk in pks
]
if quote:
bits = [urllib.parse.quote_plus(str(bit)) for bit in bits]
else:
@ -817,8 +819,10 @@ def path_with_format(request, format, extra_qs=None):
class CustomRow(OrderedDict):
# Loose imitation of sqlite3.Row which offers
# both index-based AND key-based lookups
def __init__(self, columns):
def __init__(self, columns, values=None):
self.columns = columns
if values:
self.update(values)
def __getitem__(self, key):
if isinstance(key, int):