{"id": 510235909, "node_id": "MDExOlB1bGxSZXF1ZXN0NTEwMjM1OTA5", "number": 189, "state": "closed", "locked": 0, "title": "Allow iterables other than Lists in m2m records", "user": {"value": 35681, "label": "adamwolf"}, "body": "I was playing around with sqlite-utils, creating a Roam Research dogsheep-style importer for Datasette, and ran into a slight snag.\r\n\r\nI wanted to use a generator to add an order column in an importer. It looked something like:\r\n\r\n```\r\ndef order_generator(iterable, attr=None):\r\n if attr is None:\r\n attr = \"order\"\r\n order: int = 0\r\n\r\n for i in iterable:\r\n i[attr] = order\r\n order += 1\r\n yield i\r\n```\r\n\r\nWhen I used this with `insert_all` and other things, it worked fine--but it didn't work as the `records` argument to `m2m`. I dug into it, and sqlite-utils is explicitly checking if the records argument is a list or a tuple. I flipped the check upside down, and now it checks if the argument is a mapping. If it's a mapping, it wraps it in a list, otherwise it leaves it alone.\r\n\r\n(I get that it might not really make sense to put the order column on the second table. I changed my import schema a bit, and no longer have a real example, but maybe this change still makes sense.)\r\n\r\nThe automated tests still pass, but I did not add any new ones.\r\n\r\nLet me know what you think! I'm really loving Datasette and its ecosystem; thanks for everything!", "created_at": "2020-10-26T18:47:44Z", "updated_at": "2020-10-27T16:28:37Z", "closed_at": "2020-10-27T16:24:21Z", "merged_at": "2020-10-27T16:24:21Z", "merge_commit_sha": "f045d8559a6d2cb922a2de30fbcc896a4486b82f", "assignee": null, "milestone": null, "draft": 0, "head": "93230b2acb61635b6d5070ad9c65e7221c63b75a", "base": "e4f1c7b936981de29823730c5dbef4f4ba7a4286", "author_association": "CONTRIBUTOR", "repo": {"value": 140912432, "label": "sqlite-utils"}, "url": "https://github.com/simonw/sqlite-utils/pull/189", "merged_by": null, "auto_merge": null} {"id": 510956134, "node_id": "MDExOlB1bGxSZXF1ZXN0NTEwOTU2MTM0", "number": 190, "state": "closed", "locked": 0, "title": "Progress bar for sqlite-utils insert command", "user": {"value": 9599, "label": "simonw"}, "body": "Refs #173", "created_at": "2020-10-27T18:08:53Z", "updated_at": "2020-10-27T18:16:03Z", "closed_at": "2020-10-27T18:16:03Z", "merged_at": "2020-10-27T18:16:03Z", "merge_commit_sha": "f99a23652910b03ac4669bbbb35a9b484451aabb", "assignee": null, "milestone": null, "draft": 0, "head": "62d678122a251812cd650845705ca7b9efcef86d", "base": "c7e5dd64513c0ec2b2df4c51c8df924c282417f9", "author_association": "OWNER", "repo": {"value": 140912432, "label": "sqlite-utils"}, "url": "https://github.com/simonw/sqlite-utils/pull/190", "merged_by": null, "auto_merge": null} {"id": 511005542, "node_id": "MDExOlB1bGxSZXF1ZXN0NTExMDA1NTQy", "number": 1056, "state": "closed", "locked": 0, "title": "Radical new colour scheme and base styles, courtesy of @natbat", "user": {"value": 9599, "label": "simonw"}, "body": "", "created_at": "2020-10-27T19:31:48Z", "updated_at": "2020-10-27T19:39:57Z", "closed_at": "2020-10-27T19:39:56Z", "merged_at": "2020-10-27T19:39:56Z", "merge_commit_sha": "e5f5034bcdc71e4bc62a6a155ca60eb41910c335", "assignee": null, "milestone": {"value": 6026070, "label": "0.51"}, "draft": 0, "head": "a7b2aabd5148c0ee382b583de68a4f0538f7dfb1", "base": "26bb4a268127da2c38f4241abe45444b2a6f7874", "author_association": "OWNER", "repo": {"value": 107914493, "label": "datasette"}, "url": "https://github.com/simonw/datasette/pull/1056", "merged_by": null, "auto_merge": null}