home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

22 rows where author_association = "OWNER", "updated_at" is on date 2022-11-15 and user = 9599 sorted by updated_at descending

✖
✖
✖
✖

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: issue_url, created_at (date), updated_at (date)

issue 7

  • Autocomplete text entry for filter values that correspond to facets 11
  • Update a single record in an existing table 4
  • Figure out design for JSON errors (consider RFC 7807) 2
  • Merge 1.0-dev branch back to main 2
  • Datasette 1.0 alpha upcoming release notes 1
  • Create a new table from one or more records, `sqlite-utils` style 1
  • `/db/-/create` API for creating tables 1

user 1

  • simonw · 22 ✖

author_association 1

  • OWNER · 22 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
1315812212 https://github.com/simonw/datasette/issues/1863#issuecomment-1315812212 https://api.github.com/repos/simonw/datasette/issues/1863 IC_kwDOBm6k_c5ObbN0 simonw 9599 2022-11-15T20:12:02Z 2022-11-15T20:12:02Z OWNER

If the update succeeds it will return {"ok": true}.

For consistency with /db/table/-/insert you can pass "return": true and it will return a "row" key with the now-updated full row.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Update a single record in an existing table 1425029242  
1315809867 https://github.com/simonw/datasette/issues/1863#issuecomment-1315809867 https://api.github.com/repos/simonw/datasette/issues/1863 IC_kwDOBm6k_c5ObapL simonw 9599 2022-11-15T20:09:44Z 2022-11-15T20:09:44Z OWNER

I'm also not going to implement "alter": true yet (which would add any missing columns based on the update) - I'll hold that off for a later feature.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Update a single record in an existing table 1425029242  
1315809260 https://github.com/simonw/datasette/issues/1863#issuecomment-1315809260 https://api.github.com/repos/simonw/datasette/issues/1863 IC_kwDOBm6k_c5Obafs simonw 9599 2022-11-15T20:09:11Z 2022-11-15T20:09:11Z OWNER

I'm going to use the error format I've been experimenting with here: - #1875

json { "type": "https://example.net/validation-error", "title": "Your request is not valid.", "errors": [ { "detail": "must be a positive integer", "pointer": "#/age" }, { "detail": "must be 'green', 'red' or 'blue'", "pointer": "#/profile/color" } ] } I'm not quite ready to commit to a type URL though, so I'll leave that to be solved later should I fully embrace that RFC.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Update a single record in an existing table 1425029242  
1315808062 https://github.com/simonw/datasette/issues/1863#issuecomment-1315808062 https://api.github.com/repos/simonw/datasette/issues/1863 IC_kwDOBm6k_c5ObaM- simonw 9599 2022-11-15T20:08:04Z 2022-11-15T20:08:04Z OWNER

The initial design I'm going to implement will look like this:

POST /db/table/1/-/update Authorization: Bearer xxx Content-Type: application/json json { "update": { "name": "New name" } } Any fields that are not yet columns will return an error.

Should it enforce types, in as much as an integer column should have a JSON integer passed to it, or should it allow strings containing valid integers?

I'm going to allow strings, mainly as a workaround for the fact that JavaScript integers have a maximum size.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Update a single record in an existing table 1425029242  
1315805498 https://github.com/simonw/datasette/issues/1892#issuecomment-1315805498 https://api.github.com/repos/simonw/datasette/issues/1892 IC_kwDOBm6k_c5ObZk6 simonw 9599 2022-11-15T20:05:30Z 2022-11-15T20:05:30Z OWNER

One slight concern: https://latest.datasette.io/ will increasingly reflect a version that isn't the most recent production release.

I might setup https://stable.datasette.io/ as a demo instance of the most recent non-alpha release to compensate for that.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Merge 1.0-dev branch back to main 1450312343  
1315804535 https://github.com/simonw/datasette/issues/1892#issuecomment-1315804535 https://api.github.com/repos/simonw/datasette/issues/1892 IC_kwDOBm6k_c5ObZV3 simonw 9599 2022-11-15T20:04:38Z 2022-11-15T20:04:38Z OWNER

I'll do this after the 1.0a0 release: - #1708

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Merge 1.0-dev branch back to main 1450312343  
1095675839 https://github.com/simonw/datasette/issues/1708#issuecomment-1095675839 https://api.github.com/repos/simonw/datasette/issues/1708 IC_kwDOBm6k_c5BTq-_ simonw 9599 2022-04-11T23:06:30Z 2022-11-15T19:57:53Z OWNER

Datasette 1.0 alpha 1

This alpha release is a preview of Datasette 1.0.

Datasette 1.0 marks a significant milestone in the project: it is the point from which various aspects of Datasette can be considered "stable", in that code developed against them should expect not to be broken by future releases in the 1.x series.

This will hold true until the next major version release, Datasette 2.0 - which we hope to hold off releasing for as long as possible.

The following Datasette components should be be considered stable after 1.0:

  • The plugin API. Plugins developed against 1.0 should continue to work unmodified throughout the 1.x series.
  • The JSON API. Code written that interacts with Datasette's default JSON web API should continue to work.
  • The template context. If you build custom templates against Datasette your custom pages should continue to work.

Note that none of these components will cease to introduce new features. New plugin hooks, new JSON APIs and new template context variables can be introduced without breaking existing code.

Since this alpha release previews features that will be frozen for 1.0, please test this thoroughly against your existing Datasette projects.

You can install the alpha using:

pip install datasette==1.0a0

JSON API changes

The most significant changes introduced in this new alpha concern Datasette's JSON API.

The default JSON returned by the /database/table.json endpoint has changed. It now returns an object with two keys: rows - which contains a list of objects representing the rows in the table or query, and more containing a boolean that shows if there are more rows or if this object contains them all.

json { "rows": [{ "id": 1, "name": "Name 1" }, { "id": 2, "name": "Name 2" }], "more": false } [ Initially I thought about going with next_url, which would be null if you have reached the last page of records. Maybe that would be better? But since next_url cannot be provided on query pages, should this be part of the default format at all? ]

Use ?_extra= to retrieve extra fields

The default format can be expanded using one or more ?_extra= parameters. This takes names of extra keys you would like to include. These can be comma-separated or ?_extra= can be applied multiple times.

For example:

/database/table.json?_extra=total

This adds a "total": 124 field to the returned JSON.

[ Question: if you do ?_facet=foo then do you still need to do ?_extra=facets - I think not? ]

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Datasette 1.0 alpha upcoming release notes 1200649124  
1314891228 https://github.com/simonw/datasette/issues/1890#issuecomment-1314891228 https://api.github.com/repos/simonw/datasette/issues/1890 IC_kwDOBm6k_c5OX6Xc simonw 9599 2022-11-15T07:23:01Z 2022-11-15T07:23:01Z OWNER

Annoying: Mobile Safari doesn't seem to support separate labels and values. I should probably disable this feature on that browser, at least for foreign key facets (for the moment).

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Autocomplete text entry for filter values that correspond to facets 1448143294  
1314856513 https://github.com/simonw/datasette/issues/1890#issuecomment-1314856513 https://api.github.com/repos/simonw/datasette/issues/1890 IC_kwDOBm6k_c5OXx5B simonw 9599 2022-11-15T06:56:29Z 2022-11-15T06:56:29Z OWNER

Looks like I can fix that like so: html <datalist id="datalist-_city_id"> <option label="San Francisco" value="1"></option> <option label="Los Angeles" value="2"></option> <option label="Detroit" value="3"></option> <option label="Memnonia" value="4"></option> </datalist>

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Autocomplete text entry for filter values that correspond to facets 1448143294  
1314850524 https://github.com/simonw/datasette/issues/1890#issuecomment-1314850524 https://api.github.com/repos/simonw/datasette/issues/1890 IC_kwDOBm6k_c5OXwbc simonw 9599 2022-11-15T06:48:37Z 2022-11-15T06:48:37Z OWNER

Spotted a bug with this on https://latest.datasette.io/fixtures/facetable?_facet=_city_id - the _city_id column is a foreign key, so you need to type 1 or 2 - but the autocomplete list shows the full text names for the cities.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Autocomplete text entry for filter values that correspond to facets 1448143294  
1314849867 https://github.com/simonw/datasette/issues/1890#issuecomment-1314849867 https://api.github.com/repos/simonw/datasette/issues/1890 IC_kwDOBm6k_c5OXwRL simonw 9599 2022-11-15T06:47:51Z 2022-11-15T06:47:51Z OWNER

Demo now live here: https://congress-legislators.datasettes.com/legislators/legislator_terms?_facet=party - select party and start typing.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Autocomplete text entry for filter values that correspond to facets 1448143294  
1314848432 https://github.com/simonw/datasette/issues/1890#issuecomment-1314848432 https://api.github.com/repos/simonw/datasette/issues/1890 IC_kwDOBm6k_c5OXv6w simonw 9599 2022-11-15T06:46:08Z 2022-11-15T06:46:08Z OWNER

Wrote a TIL about <datalist>: https://til.simonwillison.net/html/datalist

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Autocomplete text entry for filter values that correspond to facets 1448143294  
1314845667 https://github.com/simonw/datasette/issues/1862#issuecomment-1314845667 https://api.github.com/repos/simonw/datasette/issues/1862 IC_kwDOBm6k_c5OXvPj simonw 9599 2022-11-15T06:42:09Z 2022-11-15T06:42:32Z OWNER

I implemented this as part of /db/-/create.

https://docs.datasette.io/en/1.0-dev/json_api.html#creating-a-table-from-example-data

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Create a new table from one or more records, `sqlite-utils` style 1425011030  
1314835740 https://github.com/simonw/datasette/issues/1890#issuecomment-1314835740 https://api.github.com/repos/simonw/datasette/issues/1890 IC_kwDOBm6k_c5OXs0c simonw 9599 2022-11-15T06:30:26Z 2022-11-15T06:30:26Z OWNER

That prototype actually works really well! I'm going to add that to table.js.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Autocomplete text entry for filter values that correspond to facets 1448143294  
1314833881 https://github.com/simonw/datasette/issues/1890#issuecomment-1314833881 https://api.github.com/repos/simonw/datasette/issues/1890 IC_kwDOBm6k_c5OXsXZ simonw 9599 2022-11-15T06:27:21Z 2022-11-15T06:27:21Z OWNER

Here's a prototype: ```javascript function createDataLists() { var facetResults = document.querySelectorAll(".facet-results [data-column]"); Array.from(facetResults).forEach(function (facetResult) { // Use link text from all links in the facet result var linkTexts = Array.from( facetResult.querySelectorAll("li:not(.facet-truncated) a") ).map(function (link) { return link.textContent; }); // Create a datalist element var datalist = document.createElement("datalist"); datalist.id = "datalist-" + facetResult.dataset.column; // Create an option element for each link text linkTexts.forEach(function (linkText) { var option = document.createElement("option"); option.value = linkText; datalist.appendChild(option); }); // Add the datalist to the facet result facetResult.appendChild(datalist); }); } createDataLists();

// When any select with name=_filter_column changes, update the datalist document.body.addEventListener("change", function (event) { if (event.target.name === "_filter_column") { event.target .closest(".filter-row") .querySelector(".filter-value") .setAttribute("list", "datalist-" + event.target.value); } }); ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Autocomplete text entry for filter values that correspond to facets 1448143294  
1314829751 https://github.com/simonw/datasette/issues/1890#issuecomment-1314829751 https://api.github.com/repos/simonw/datasette/issues/1890 IC_kwDOBm6k_c5OXrW3 simonw 9599 2022-11-15T06:20:50Z 2022-11-15T06:20:50Z OWNER

This finds the right links on the page:

document.querySelectorAll('.facet-results [data-column] li:not(.facet-truncated) a')
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Autocomplete text entry for filter values that correspond to facets 1448143294  
1314825019 https://github.com/simonw/datasette/issues/1890#issuecomment-1314825019 https://api.github.com/repos/simonw/datasette/issues/1890 IC_kwDOBm6k_c5OXqM7 simonw 9599 2022-11-15T06:13:36Z 2022-11-15T06:13:36Z OWNER

This could start out as a purely JavaScript enhancement for pages that already figured out the available values through faceting, like you suggested.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Autocomplete text entry for filter values that correspond to facets 1448143294  
1314823752 https://github.com/simonw/datasette/issues/1890#issuecomment-1314823752 https://api.github.com/repos/simonw/datasette/issues/1890 IC_kwDOBm6k_c5OXp5I simonw 9599 2022-11-15T06:11:49Z 2022-11-15T06:11:49Z OWNER

I tried this out on https://congress-legislators.datasettes.com/legislators/legislator_terms for the party column - here's the demo:

I made this work by dropping the following HTML into the page in the browser DevTools: ```html <datalist id="party">

<option value="Anti-Administration"> <option value="Pro-Administration"> <option value="Republican"> <option value="Federalist"> <option value="Democratic Republican"> <option value="Pro-administration"> <option value="Anti-administration"> <option value="Unknown"> <option value="Adams"> <option value="Jackson"> <option value="Jackson Republican"> <option value="Crawford Republican"> <option value="Whig"> <option value="Jacksonian Republican"> <option value="Jacksonian"> <option value="Anti-Jacksonian"> <option value="Adams Democrat"> <option value="Nullifier"> <option value="Anti Mason"> <option value="Anti Masonic"> <option value="Anti Jacksonian"> <option value="Democrat"> <option value="Anti Jackson"> <option value="Union Democrat"> <option value="Conservative"> <option value="Ind. Democrat"> <option value="Independent"> <option value="Law and Order"> <option value="American"> <option value="Liberty"> <option value="Free Soil"> <option value="Ind. Republican-Democrat"> <option value="Ind. Whig"> <option value="Unionist"> <option value="States Rights"> <option value="Anti-Lecompton Democrat"> <option value="Constitutional Unionist"> <option value="Independent Democrat"> <option value="Unconditional Unionist"> <option value="Conservative Republican"> <option value="Ind. Republican"> <option value="Liberal Republican"> <option value="National Greenbacker"> <option value="Readjuster Democrat"> <option value="Readjuster"> <option value="Union"> <option value="Union Labor"> <option value="Populist"> <option value="Silver Republican"> <option value="Free Silver"> <option value="Silver"> <option value="Democratic and Union Labor"> <option value="Progressive Republican"> <option value="Progressive"> <option value="Prohibitionist"> <option value="Socialist"> <option value="Farmer-Labor"> <option value="American Labor"> <option value="Nonpartisan"> <option value="Coalitionist"> <option value="Popular Democrat"> <option value="Liberal"> <option value="New Progressive"> <option value="Republican-Conservative"> <option value="Democrat-Liberal"> <option value="AL"> <option value="Libertarian"> </datalist> ``` And then adding `list="party"` to the input element in the filter form.
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Autocomplete text entry for filter values that correspond to facets 1448143294  
1314821337 https://github.com/simonw/datasette/issues/1890#issuecomment-1314821337 https://api.github.com/repos/simonw/datasette/issues/1890 IC_kwDOBm6k_c5OXpTZ simonw 9599 2022-11-15T06:08:19Z 2022-11-15T06:08:19Z OWNER

Oh interesting... this doesn't even need to be attached to the visible faceting feature, necessarily: Datasette could try to detect when a column has a limited number of options (which the faceting code handles already) and could turn those into an auto-complete interface.

There's actually a native HTML element for this these days: the <datalist> https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Autocomplete text entry for filter values that correspond to facets 1448143294  
1314813205 https://github.com/simonw/datasette/issues/1882#issuecomment-1314813205 https://api.github.com/repos/simonw/datasette/issues/1882 IC_kwDOBm6k_c5OXnUV simonw 9599 2022-11-15T06:00:41Z 2022-11-15T06:00:41Z OWNER

Documentation:

  • https://docs.datasette.io/en/1.0-dev/json_api.html#creating-a-table
  • https://docs.datasette.io/en/1.0-dev/json_api.html#creating-a-table-from-example-data

Wrote a TIL about how I wrote some of those tests with Copilot: https://til.simonwillison.net/gpt3/writing-test-with-copilot

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
`/db/-/create` API for creating tables 1435294468  
1314620086 https://github.com/simonw/datasette/issues/1875#issuecomment-1314620086 https://api.github.com/repos/simonw/datasette/issues/1875 IC_kwDOBm6k_c5OW4K2 simonw 9599 2022-11-15T01:09:56Z 2022-11-15T01:09:56Z OWNER

Rough initial prototype: ```diff diff --git a/datasette/views/table.py b/datasette/views/table.py index 8b987221..518ac578 100644 --- a/datasette/views/table.py +++ b/datasette/views/table.py @@ -1103,19 +1103,30 @@ class TableInsertView(BaseView): except json.JSONDecodeError as e: return _errors(["Invalid JSON: {}".format(e)]) if not isinstance(data, dict): - return _errors(["JSON must be a dictionary"]) + return _errors([{"detail": "JSON must be a dictionary", "pointer": "#/"}]) keys = data.keys()

     # keys must contain "row" or "rows"
     if "row" not in keys and "rows" not in keys:
         return _errors(['JSON must have one or other of "row" or "rows"'])
     rows = []
  • was_single_row = False if "row" in keys: if "rows" in keys:
  • return _errors(['Cannot use "row" and "rows" at the same time'])
  • return _errors(
  • [
  • {
  • "detail": 'Cannot use "row" and "rows" at the same time',
  • "pointer": "#/row",
  • }
  • ]
  • )
  • was_single_row = True row = data["row"] if not isinstance(row, dict):
  • return _errors(['"row" must be a dictionary'])
  • return _errors(
  • [{"detail": '"row" must be a dictionary', "pointer": "#/row"}]
  • ) rows = [row] data["return"] = True else: @@ -1152,9 +1163,12 @@ class TableInsertView(BaseView): invalid_columns = set(row.keys()) - columns if invalid_columns: errors.append(
  • "Row {} has invalid columns: {}".format(
  • i, ", ".join(sorted(invalid_columns))
  • )
  • {
  • "detail": "Invalid columns: {}".format(
  • ", ".join(sorted(invalid_columns))
  • ),
  • "pointer": "#/blah/",
  • } ) if errors: return _errors(errors) ```
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Figure out design for JSON errors (consider RFC 7807) 1430797211  
1314615592 https://github.com/simonw/datasette/issues/1875#issuecomment-1314615592 https://api.github.com/repos/simonw/datasette/issues/1875 IC_kwDOBm6k_c5OW3Eo simonw 9599 2022-11-15T01:04:28Z 2022-11-15T01:04:28Z OWNER

Worth noting this bit in RFC 7807:

The fictional problem type here defines the "errors" extension, an array that describes the details of each validation error. Each member is an object containing "detail" to describe the issue, and "pointer" to locate the problem within the request's content using a JSON Pointer [JSON-POINTER].

So the list of "errors" with JSON Pointer isn't technically part of the spec, it's an imaginary extension.

It fits what I need to do though, so I'm inclined to stick with it anyway.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Figure out design for JSON errors (consider RFC 7807) 1430797211  

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
, [performed_via_github_app] TEXT);
CREATE INDEX [idx_issue_comments_issue]
                ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
                ON [issue_comments] ([user]);
Powered by Datasette · Queries took 480.854ms · About: github-to-sqlite
  • Sort ascending
  • Sort descending
  • Facet by this
  • Hide this column
  • Show all columns
  • Show not-blank rows