{"html_url": "https://github.com/simonw/sqlite-utils/issues/514#issuecomment-1539078429", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/514", "id": 1539078429, "node_id": "IC_kwDOCGYnMM5bvHkd", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-05-08T21:27:40Z", "updated_at": "2023-05-08T21:27:40Z", "author_association": "OWNER", "body": "Dupe of:\r\n- #538", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1465194249, "label": "upsert of new row with check constraints fails"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/514#issuecomment-1539079507", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/514", "id": 1539079507, "node_id": "IC_kwDOCGYnMM5bvH1T", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-05-08T21:28:37Z", "updated_at": "2023-05-08T21:28:37Z", "author_association": "OWNER", "body": "> This means that a table with NON NULL (or other constraint) columns that aren't part of the pkey can't have new rows upserted.\r\n\r\nHuh... on that basis, it's possible my fix in https://github.com/simonw/sqlite-utils/commit/2376c452a56b0c3e75e7ca698273434e32945304 is incomplete. I only covered the 'not null' case.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1465194249, "label": "upsert of new row with check constraints fails"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/514#issuecomment-1539094287", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/514", "id": 1539094287, "node_id": "IC_kwDOCGYnMM5bvLcP", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-05-08T21:44:11Z", "updated_at": "2023-05-08T21:44:11Z", "author_association": "OWNER", "body": "OK, this fails silently:\r\n```python\r\nimport sqlite_utils\r\ndb = sqlite_utils.Database(memory=True)\r\ndb.execute('''CREATE TABLE employees (\r\n id INTEGER PRIMARY KEY,\r\n name TEXT,\r\n age INTEGER,\r\n salary REAL,\r\n CHECK (salary is not null and salary > 0)\r\n);''')\r\ndb[\"employees\"].upsert({\"id\": 1, \"name\": \"Bob\"}, pk=\"id\")\r\nlist(db[\"employees\"].rows)\r\n````\r\nIt outputs:\r\n```python\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": 1465194249, "label": "upsert of new row with check constraints fails"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/514#issuecomment-1539099703", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/514", "id": 1539099703, "node_id": "IC_kwDOCGYnMM5bvMw3", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-05-08T21:50:06Z", "updated_at": "2023-05-08T21:50:06Z", "author_association": "OWNER", "body": "Applying the fix from the PR here doesn't fix the above problem either:\r\n- https://github.com/simonw/sqlite-utils/pull/515\r\n\r\nSo it looks like these kinds of `check` constraints currently aren't compatible with how `upsert()` works.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1465194249, "label": "upsert of new row with check constraints fails"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/514#issuecomment-1539100300", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/514", "id": 1539100300, "node_id": "IC_kwDOCGYnMM5bvM6M", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-05-08T21:50:51Z", "updated_at": "2023-05-08T21:50:51Z", "author_association": "OWNER", "body": "Seeing as `sqlite-utils` doesn't currently provide mechanisms for adding `check` constraints like this I'm going to leave this - I'm happy with the fix I put in for the `not null` constraints.", "reactions": "{\"total_count\": 1, \"+1\": 1, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1465194249, "label": "upsert of new row with check constraints fails"}, "performed_via_github_app": null}