mirror of
https://github.com/simonw/datasette.git
synced 2026-06-24 17:54:35 +02:00
Fix _col=<pk> producing duplicate column in output (#2774)
Closes #1975
This commit is contained in:
parent
a913ba372a
commit
463eea2bd0
2 changed files with 12 additions and 2 deletions
|
|
@ -1606,8 +1606,8 @@ async def _columns_to_select(table_columns, pks, request):
|
|||
"_col={} - invalid columns".format(", ".join(bad_columns)),
|
||||
status=400,
|
||||
)
|
||||
# De-duplicate maintaining order:
|
||||
columns.extend(dict.fromkeys(_cols))
|
||||
# De-duplicate maintaining order, skipping columns already added (pks):
|
||||
columns.extend(c for c in dict.fromkeys(_cols) if c not in columns)
|
||||
if "_nocol" in request.args:
|
||||
# Return all columns EXCEPT these
|
||||
bad_columns = [
|
||||
|
|
|
|||
|
|
@ -1420,6 +1420,16 @@ def test_generated_columns_are_visible_in_datasette():
|
|||
"/fixtures/facetable.json?_col=state&_col=state",
|
||||
["pk", "state"],
|
||||
),
|
||||
(
|
||||
# https://github.com/simonw/datasette/issues/1975
|
||||
"/fixtures/facetable.json?_col=pk&_col=state",
|
||||
["pk", "state"],
|
||||
),
|
||||
(
|
||||
# https://github.com/simonw/datasette/issues/1975
|
||||
"/fixtures/facetable.json?_col=pk",
|
||||
["pk"],
|
||||
),
|
||||
(
|
||||
"/fixtures/facetable.json?_col=state&_col=created&_nocol=created",
|
||||
["pk", "state"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue