{"html_url": "https://github.com/simonw/datasette/pull/1999#issuecomment-1474704790", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1999", "id": 1474704790, "node_id": "IC_kwDOBm6k_c5X5jWW", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-03-18T04:52:59Z", "updated_at": "2023-03-18T04:52:59Z", "author_association": "OWNER", "body": "Here are the next set of tests to get passing:\r\n```\r\n% pytest tests/test_table_api.py\r\n```\r\n```\r\nFAILED tests/test_table_api.py::test_facets[/fixtures/facetable.json?_facet=state&_facet=_city_id-expected_facet_results0] - KeyError: 'name'\r\nFAILED tests/test_table_api.py::test_facets[/fixtures/facetable.json?_facet=state&_facet=_city_id&state=MI-expected_facet_results1] - KeyError: 'name'\r\nFAILED tests/test_table_api.py::test_facets[/fixtures/facetable.json?_facet=planet_int-expected_facet_results2] - KeyError: 'name'\r\nFAILED tests/test_table_api.py::test_facets[/fixtures/facetable.json?_facet=planet_int&planet_int=1-expected_facet_results3] - KeyError: 'name'\r\nFAILED tests/test_table_api.py::test_suggested_facets - KeyError: 'suggested_facets'\r\nFAILED tests/test_table_api.py::test_allow_facet_off - KeyError: 'suggested_facets'\r\nFAILED tests/test_table_api.py::test_suggest_facets_off - KeyError: 'suggested_facets'\r\nFAILED tests/test_table_api.py::test_nofacet[True] - KeyError: 'suggested_facets'\r\nFAILED tests/test_table_api.py::test_nofacet[False] - KeyError: 'suggested_facets'\r\nFAILED tests/test_table_api.py::test_nosuggest[True] - KeyError: 'suggested_facets'\r\nFAILED tests/test_table_api.py::test_nosuggest[False] - KeyError: 'suggested_facets'\r\nFAILED tests/test_table_api.py::test_nocount[True-None] - KeyError: 'count'\r\nFAILED tests/test_table_api.py::test_nocount[False-15] - KeyError: 'count'\r\nFAILED tests/test_table_api.py::test_expand_labels - AssertionError: assert {'13': {'_cit...:00:00', ...}} == {'13': {'_cit...:00:00', ...}}\r\nFAILED tests/test_table_api.py::test_expand_label - AssertionError: assert {'1': {'forei...l': '1', ...}} == {'1': {'forei...': '1'}, ...}}\r\nFAILED tests/test_table_api.py::test_ttl_parameter[/fixtures/facetable.json-max-age=5] - KeyError: 'Cache-Control'\r\nFAILED tests/test_table_api.py::test_ttl_parameter[/fixtures/facetable.json?_ttl=invalid-max-age=5] - KeyError: 'Cache-Control'\r\nFAILED tests/test_table_api.py::test_ttl_parameter[/fixtures/facetable.json?_ttl=10-max-age=10] - KeyError: 'Cache-Control'\r\nFAILED tests/test_table_api.py::test_ttl_parameter[/fixtures/facetable.json?_ttl=0-no-cache] - KeyError: 'Cache-Control'\r\nFAILED tests/test_table_api.py::test_infinity_returned_as_null - AssertionError: assert [{'rowid': 1,...'value': 1.5}] == [{'rowid': 1,...'value': 1.5}]\r\nFAILED tests/test_table_api.py::test_null_and_compound_foreign_keys_are_not_expanded - AssertionError: assert [{'foreign_ke...': None, ...}] == [{'foreign_ke...': None, ...}]\r\nFAILED tests/test_table_api.py::test_binary_data_in_json[/fixtures/binary_data.json?_shape=array-expected_json0-None] - assert [{'data': \"b'..., 'rowid': 3}] == [{'data': {'$..., 'rowid': 3}]\r\nFAILED tests/test_table_api.py::test_binary_data_in_json[/fixtures/binary_data.json?_shape=array&_nl=on-None-{\"rowid\": 1, \"data\": {\"$base64\": true, \"encoded\": \"FRwCx60F/g==\"}}\\n{\"rowid\": 2, \"data\": {\"$base64\": true, \"encoded\": \"FRwDx60F/g==\"}}\\n{\"rowid\": 3, \"data\": null}] - assert '{\"ok\": false...title\": null}' == '{\"rowid\": 1,...\"data\": null}'\r\nFAILED tests/test_table_api.py::test_paginate_using_link_header[] - assert 1 == 21\r\nFAILED tests/test_table_api.py::test_paginate_using_link_header[?_shape=arrays] - assert 1 == 21\r\nFAILED tests/test_table_api.py::test_paginate_using_link_header[?_shape=arrayfirst] - assert 400 == 200\r\nFAILED tests/test_table_api.py::test_paginate_using_link_header[?_shape=object] - assert 1 == 21\r\nFAILED tests/test_table_api.py::test_paginate_using_link_header[?_shape=objects] - assert 1 == 21\r\nFAILED tests/test_table_api.py::test_paginate_using_link_header[?_shape=array] - assert 1 == 21\r\nFAILED tests/test_table_api.py::test_paginate_using_link_header[?_shape=array&_nl=on] - assert 1 == 21\r\nFAILED tests/test_table_api.py::test_col_nocol[/fixtures/facetable.json?_col=created-expected_columns0] - KeyError: 'columns'\r\nFAILED tests/test_table_api.py::test_col_nocol[/fixtures/facetable.json?_nocol=created-expected_columns1] - KeyError: 'columns'\r\nFAILED tests/test_table_api.py::test_col_nocol[/fixtures/facetable.json?_col=state&_col=created-expected_columns2] - KeyError: 'columns'\r\nFAILED tests/test_table_api.py::test_col_nocol[/fixtures/facetable.json?_col=state&_col=state-expected_columns3] - KeyError: 'columns'\r\nFAILED tests/test_table_api.py::test_col_nocol[/fixtures/facetable.json?_col=state&_col=created&_nocol=created-expected_columns4] - KeyError: 'columns'\r\nFAILED tests/test_table_api.py::test_col_nocol[/fixtures/facetable.json?_nocol=state&_facet=state-expected_columns5] - KeyError: 'columns'\r\nFAILED tests/test_table_api.py::test_col_nocol[/fixtures/simple_view.json?_nocol=content-expected_columns6] - KeyError: 'columns'\r\nFAILED tests/test_table_api.py::test_col_nocol[/fixtures/simple_view.json?_col=content-expected_columns7] - KeyError: 'columns'\r\n============================================================================= 38 failed, 73 passed, 1 xfailed in 7.25s =============================================================================\r\n```\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1551694938, "label": "?_extra= support (draft)"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1999#issuecomment-1475003292", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1999", "id": 1475003292, "node_id": "IC_kwDOBm6k_c5X6sOc", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-03-18T21:46:20Z", "updated_at": "2023-03-18T21:46:20Z", "author_association": "OWNER", "body": "Now 25 failures in `test_table_api.py`:\r\n```\r\nFAILED tests/test_table_api.py::test_expand_labels - assert {'2': {'pk': 2, 'created': '2019-01-14 08:00:00', 'planet_int': 1, 'on_earth': 1, 'state': 'CA', '_city_id': 1, '_neighborhood': 'Dogpatch', 'tags': '[\"tag1\", \"tag3\"]', 'complex_array'...\r\nFAILED tests/test_table_api.py::test_expand_label - AssertionError: assert {'1': {'pk': '1', 'foreign_key_with_label': '1', 'foreign_key_with_blank_label': '3', 'foreign_key_with_no_label': '1', 'foreign_key_compound_pk1': 'a', 'foreign_key_co...\r\nFAILED tests/test_table_api.py::test_ttl_parameter[/fixtures/facetable.json-max-age=5] - KeyError: 'Cache-Control'\r\nFAILED tests/test_table_api.py::test_ttl_parameter[/fixtures/facetable.json?_ttl=invalid-max-age=5] - KeyError: 'Cache-Control'\r\nFAILED tests/test_table_api.py::test_ttl_parameter[/fixtures/facetable.json?_ttl=10-max-age=10] - KeyError: 'Cache-Control'\r\nFAILED tests/test_table_api.py::test_ttl_parameter[/fixtures/facetable.json?_ttl=0-no-cache] - KeyError: 'Cache-Control'\r\nFAILED tests/test_table_api.py::test_infinity_returned_as_null - AssertionError: assert [{'rowid': 1, 'value': inf}, {'rowid': 2, 'value': -inf}, {'rowid': 3, 'value': 1.5}] == [{'rowid': 1, 'value': None}, {'rowid': 2, 'value': None}, {'rowid': 3, 'value'...\r\nFAILED tests/test_table_api.py::test_null_and_compound_foreign_keys_are_not_expanded - AssertionError: assert [{'pk': '1', 'foreign_key_with_label': '1', 'foreign_key_with_blank_label': '3', 'foreign_key_with_no_label': '1', 'foreign_key_compound_pk1': 'a', 'foreign_key_compoun...\r\nFAILED tests/test_table_api.py::test_binary_data_in_json[/fixtures/binary_data.json?_shape=array-expected_json0-None] - assert [{'rowid': 1, 'data': \"b'\\\\x15\\\\x1c\\\\x02\\\\xc7\\\\xad\\\\x05\\\\xfe'\"}, {'rowid': 2, 'data': \"b'\\\\x15\\\\x1c\\\\x03\\\\xc7\\\\xad\\\\x05\\\\xfe'\"}, {'rowid': 3, 'data': None}] == [{'rowid': 1, 'data': {'...\r\nFAILED tests/test_table_api.py::test_binary_data_in_json[/fixtures/binary_data.json?_shape=array&_nl=on-None-{\"rowid\": 1, \"data\": {\"$base64\": true, \"encoded\": \"FRwCx60F/g==\"}}\\n{\"rowid\": 2, \"data\": {\"$base64\": true, \"encoded\": \"FRwDx60F/g==\"}}\\n{\"rowid\": 3, \"data\": null}] - assert '{\"ok\": false, \"error\": \"Object of type bytes is not JSON serializable\", \"status\": 500, \"title\": null}' == '{\"rowid\": 1, \"data\": {\"$base64\": true, \"encoded\": \"FRwCx60F/g==\"}}\\n{\"rowid\"...\r\nFAILED tests/test_table_api.py::test_paginate_using_link_header[] - assert 1 == 21\r\nFAILED tests/test_table_api.py::test_paginate_using_link_header[?_shape=arrays] - assert 1 == 21\r\nFAILED tests/test_table_api.py::test_paginate_using_link_header[?_shape=arrayfirst] - assert 400 == 200\r\nFAILED tests/test_table_api.py::test_paginate_using_link_header[?_shape=object] - assert 1 == 21\r\nFAILED tests/test_table_api.py::test_paginate_using_link_header[?_shape=objects] - assert 1 == 21\r\nFAILED tests/test_table_api.py::test_paginate_using_link_header[?_shape=array] - assert 1 == 21\r\nFAILED tests/test_table_api.py::test_paginate_using_link_header[?_shape=array&_nl=on] - assert 1 == 21\r\nFAILED tests/test_table_api.py::test_col_nocol[/fixtures/facetable.json?_col=created-expected_columns0] - KeyError: 'columns'\r\nFAILED tests/test_table_api.py::test_col_nocol[/fixtures/facetable.json?_nocol=created-expected_columns1] - KeyError: 'columns'\r\nFAILED tests/test_table_api.py::test_col_nocol[/fixtures/facetable.json?_col=state&_col=created-expected_columns2] - KeyError: 'columns'\r\nFAILED tests/test_table_api.py::test_col_nocol[/fixtures/facetable.json?_col=state&_col=state-expected_columns3] - KeyError: 'columns'\r\nFAILED tests/test_table_api.py::test_col_nocol[/fixtures/facetable.json?_col=state&_col=created&_nocol=created-expected_columns4] - KeyError: 'columns'\r\nFAILED tests/test_table_api.py::test_col_nocol[/fixtures/facetable.json?_nocol=state&_facet=state-expected_columns5] - KeyError: 'columns'\r\nFAILED tests/test_table_api.py::test_col_nocol[/fixtures/simple_view.json?_nocol=content-expected_columns6] - KeyError: 'columns'\r\nFAILED tests/test_table_api.py::test_col_nocol[/fixtures/simple_view.json?_col=content-expected_columns7] - KeyError: 'columns'\r\n============================================================================= 25 failed, 86 passed, 1 xfailed in 7.18s =============================================================================\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1551694938, "label": "?_extra= support (draft)"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1999#issuecomment-1475016834", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1999", "id": 1475016834, "node_id": "IC_kwDOBm6k_c5X6viC", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-03-18T22:30:31Z", "updated_at": "2023-03-18T22:30:31Z", "author_association": "OWNER", "body": "`test_paginate_using_link_header` will be tricky.\r\n\r\nThe reason the tests are failing is that `json_renderer()` attempts to populate the `link` header using `data[\"next_url\"]` - but that's not present unless `?_extra=next_url` has been passed:\r\n\r\nhttps://github.com/simonw/datasette/blob/2f38479dcc81f11a4362f4e28511fa88afc34e61/datasette/renderer.py#L101-L102\r\n\r\nBut I can only rely on `next` being present, not `next_url`.\r\n\r\nI thought I could maybe assemble the `link` header using `next`, by turning that into a `next_url` link - but there's some custom logic which kicks in for pagination against SQL views (offset/limit pagination) to calculate the `next_url` which isn't easily replicable at the `json_renderer()` layer, in the `_next_value_and_url()` utility function:\r\n\r\nhttps://github.com/simonw/datasette/blob/2f38479dcc81f11a4362f4e28511fa88afc34e61/datasette/views/table.py#L2275-L2282\r\n\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1551694938, "label": "?_extra= support (draft)"}, "performed_via_github_app": null}