home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

5 rows where issue = 1082651698 and user = 9599 sorted by updated_at descending

✖
✖
✖

✎ View and edit SQL

This data as json, CSV (advanced)

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

user 1

  • simonw · 5 ✖

issue 1

  • Support for CHECK constraints · 5 ✖

author_association 1

  • OWNER 5
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
1255341690 https://github.com/simonw/sqlite-utils/issues/358#issuecomment-1255341690 https://api.github.com/repos/simonw/sqlite-utils/issues/358 IC_kwDOCGYnMM5K0v56 simonw 9599 2022-09-22T17:35:23Z 2022-09-22T17:35:23Z OWNER

Make me think also that sqlite-utils create-table should have an option to dump out the SQL without actually creating the table.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support for CHECK constraints 1082651698  
1255340974 https://github.com/simonw/sqlite-utils/issues/358#issuecomment-1255340974 https://api.github.com/repos/simonw/sqlite-utils/issues/358 IC_kwDOCGYnMM5K0vuu simonw 9599 2022-09-22T17:34:45Z 2022-09-22T17:34:45Z OWNER

A few other recipes off the top of my head:

  • title:maxlength:20 - set a max length, length(title) <= 20
  • created:date - check for yyyy-mm-dd date, select :date == date(:date) is not null (demo)
  • age:positiveint - check age is a positive integer, printf('%', age) = age and age > 0 (untested)
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support for CHECK constraints 1082651698  
1255333969 https://github.com/simonw/sqlite-utils/issues/358#issuecomment-1255333969 https://api.github.com/repos/simonw/sqlite-utils/issues/358 IC_kwDOCGYnMM5K0uBR simonw 9599 2022-09-22T17:29:09Z 2022-09-22T17:29:09Z OWNER

Quick demo of a check constraint for JSON validation: sqlite> create table test (id integer primary key, tags text, check (json(tags) is not null)); sqlite> sqlite> insert into test (tags ('["one", "two"]'); sqlite> insert into test (tags) values ('["one", "two"'); Error: stepping, malformed JSON (1)

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support for CHECK constraints 1082651698  
1255332217 https://github.com/simonw/sqlite-utils/issues/358#issuecomment-1255332217 https://api.github.com/repos/simonw/sqlite-utils/issues/358 IC_kwDOCGYnMM5K0tl5 simonw 9599 2022-09-22T17:27:34Z 2022-09-22T17:27:34Z OWNER

I've been thinking about this more recently.

I think the first place to explore these will be in the create-table command (and underlying APIs).

Relevant docs: https://www.sqlite.org/lang_createtable.html#check_constraints

A CHECK constraint may be attached to a column definition or specified as a table constraint. In practice it makes no difference. Each time a new row is inserted into the table or an existing row is updated, the expression associated with each CHECK constraint is evaluated and cast to a NUMERIC value in the same way as a CAST expression. If the result is zero (integer value 0 or real value 0.0), then a constraint violation has occurred. If the CHECK expression evaluates to NULL, or any other non-zero value, it is not a constraint violation. The expression of a CHECK constraint may not contain a subquery.

Something like this:

sqlite-utils create-table data.db entries id integer title text tags text --pk id --check tags:json

Where --check tags:json uses a pre-baked recipe for using the SQLite JSON function to check that the content is valid JSON and reject it otherwise.

Then can bundle a bunch of other pre-baked recipes, but also support the following:

--check 'x > 3' --check 'length(phone) >= 10'

The besign reason for the column:recipe format here is to reuse --check for both pre-defined recipes that affect a single column AND for freeform expressions that get added to the end of the table.

Detecting column name:recipe with a regex feels safe to me.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support for CHECK constraints 1082651698  
996232461 https://github.com/simonw/sqlite-utils/issues/358#issuecomment-996232461 https://api.github.com/repos/simonw/sqlite-utils/issues/358 IC_kwDOCGYnMM47YU0N simonw 9599 2021-12-16T22:10:39Z 2021-12-16T22:10:39Z OWNER

This goes beyond the transform() method - the curious methods that create new SQL tables could benefit from the ability to add CHECK constraints too.

I haven't used these myself, do you have any CREATE TABLE examples that use them that you can share?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support for CHECK constraints 1082651698  

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 510.251ms · About: github-to-sqlite
  • Sort ascending
  • Sort descending
  • Facet by this
  • Hide this column
  • Show all columns
  • Show not-blank rows