home / github

Menu
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

7 rows where issue = 1058196641

✎ View and edit SQL

This data as json, CSV (advanced)

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

id ▼ html_url issue_url node_id user created_at updated_at author_association body reactions issue performed_via_github_app
973800795 https://github.com/simonw/sqlite-utils/issues/342#issuecomment-973800795 https://api.github.com/repos/simonw/sqlite-utils/issues/342 IC_kwDOCGYnMM46CwVb simonw 9599 2021-11-19T06:54:08Z 2021-11-19T06:54:08Z OWNER Looking at the code for `lookup()` it currently hard-codes `pk` to `"id"` - but it actually only calls `.insert()` in two places, both of which could be passed extra arguments. https://github.com/simonw/sqlite-utils/blob/3b8abe608796e99e4ffc5f3f4597a85e605c0e9b/sqlite_utils/db.py#L2756-L2763 {"total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} Extra options to `lookup()` which get passed to `insert()` 1058196641  
973801650 https://github.com/simonw/sqlite-utils/issues/342#issuecomment-973801650 https://api.github.com/repos/simonw/sqlite-utils/issues/342 IC_kwDOCGYnMM46Cwiy simonw 9599 2021-11-19T06:55:56Z 2021-11-19T06:55:56Z OWNER `pk` needs to be an explicit argument to `.lookup()`. The rest could be `**kwargs` passed through to `.insert()`, like this hacked together version (docstring removed for brevity): ```python def lookup( self, lookup_values: Dict[str, Any], extra_values: Optional[Dict[str, Any]] = None, pk="id", **insert_kwargs, ): """ assert isinstance(lookup_values, dict) if extra_values is not None: assert isinstance(extra_values, dict) combined_values = dict(lookup_values) if extra_values is not None: combined_values.update(extra_values) if self.exists(): self.add_missing_columns([combined_values]) unique_column_sets = [set(i.columns) for i in self.indexes] if set(lookup_values.keys()) not in unique_column_sets: self.create_index(lookup_values.keys(), unique=True) wheres = ["[{}] = ?".format(column) for column in lookup_values] rows = list( self.rows_where( " and ".join(wheres), [value for _, value in lookup_values.items()] ) ) try: return rows[0][pk] except IndexError: return self.insert(combined_values, pk=pk, **insert_kwargs).last_pk else: pk = self.insert(combined_values, pk=pk, **insert_kwargs).last_pk self.create_index(lookup_values.keys(), unique=True) return pk ``` I think I'll explicitly list the parameters, mainly so they can be typed and covered by automatic documentation. I do worry that I'll add more keyword arguments to `.insert()` in the future and forget to mirror them to `.lookup()` though. {"total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} Extra options to `lookup()` which get passed to `insert()` 1058196641  
973802308 https://github.com/simonw/sqlite-utils/issues/342#issuecomment-973802308 https://api.github.com/repos/simonw/sqlite-utils/issues/342 IC_kwDOCGYnMM46CwtE simonw 9599 2021-11-19T06:57:37Z 2021-11-19T06:57:37Z OWNER Here's the current full method signature for `.insert()`: https://github.com/simonw/sqlite-utils/blob/3b8abe608796e99e4ffc5f3f4597a85e605c0e9b/sqlite_utils/db.py#L2462-L2477 I could add a test which uses introspection (`inspect.signature(method).parameters`) to confirm that `.lookup()` has a super-set of the arguments accepted by `.insert()`. {"total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} Extra options to `lookup()` which get passed to `insert()` 1058196641  
973802469 https://github.com/simonw/sqlite-utils/issues/342#issuecomment-973802469 https://api.github.com/repos/simonw/sqlite-utils/issues/342 IC_kwDOCGYnMM46Cwvl simonw 9599 2021-11-19T06:58:03Z 2021-11-19T06:58:03Z OWNER Also: I don't think `ignore=` and `replace=` make sense in the context of `lookup()`. {"total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} Extra options to `lookup()` which get passed to `insert()` 1058196641  
973802766 https://github.com/simonw/sqlite-utils/issues/342#issuecomment-973802766 https://api.github.com/repos/simonw/sqlite-utils/issues/342 IC_kwDOCGYnMM46Cw0O simonw 9599 2021-11-19T06:58:45Z 2021-11-19T06:58:45Z OWNER And neither does `hash_id`. On that basis I'm going to specifically list the ones that DO make sense, and hope that I remember to add any new ones in the future. I can add a code comment hint to `.insert()` about that. {"total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} Extra options to `lookup()` which get passed to `insert()` 1058196641  
973802998 https://github.com/simonw/sqlite-utils/issues/342#issuecomment-973802998 https://api.github.com/repos/simonw/sqlite-utils/issues/342 IC_kwDOCGYnMM46Cw32 simonw 9599 2021-11-19T06:59:22Z 2021-11-19T06:59:32Z OWNER I don't think I need the `DEFAULT` defaults for `.insert()` either, since it just passes through to `.insert()`. {"total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} Extra options to `lookup()` which get passed to `insert()` 1058196641  
973820125 https://github.com/simonw/sqlite-utils/issues/342#issuecomment-973820125 https://api.github.com/repos/simonw/sqlite-utils/issues/342 IC_kwDOCGYnMM46C1Dd simonw 9599 2021-11-19T07:25:55Z 2021-11-19T07:25:55Z OWNER `alter=True` doesn't make sense to support here either, because `.lookup()` already adds missing columns: https://github.com/simonw/sqlite-utils/blob/3b8abe608796e99e4ffc5f3f4597a85e605c0e9b/sqlite_utils/db.py#L2743-L2746 {"total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} Extra options to `lookup()` which get passed to `insert()` 1058196641  

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 97.317ms · About: simonw/datasette-graphql