From 30727388d80cc87f0472300298ae63b383be2f26 Mon Sep 17 00:00:00 2001 From: "Hitalo M." Date: Mon, 12 Aug 2024 12:26:47 -0300 Subject: [PATCH] fix(database): IntegrityError --- NEWS.rst | 7 +++++++ src/korone/__init__.py | 2 +- src/korone/database/sqlite/table.py | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/NEWS.rst b/NEWS.rst index 77bd68f47..73ffe50b3 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -15,6 +15,13 @@ Changelog .. towncrier release notes start +1.0.1 (2024-08-12) +================== + +Bug Fixes +--------- + +- Fixed an `IntegrityError` in `korone.database.sqlite.connection` within the `_execute` method. The error occurred due to a UNIQUE constraint violation on `Users.id`. 1.0.0 (2024-08-12) =================== diff --git a/src/korone/__init__.py b/src/korone/__init__.py index af5b99817..6baca9bd4 100644 --- a/src/korone/__init__.py +++ b/src/korone/__init__.py @@ -7,7 +7,7 @@ from .utils.i18n import create_i18n_instance -__version__ = "1.0.0" +__version__ = "1.0.1" cache = Cache() cache.setup("redis://localhost", client_side=True) diff --git a/src/korone/database/sqlite/table.py b/src/korone/database/sqlite/table.py index 250a5a935..59b312f3e 100644 --- a/src/korone/database/sqlite/table.py +++ b/src/korone/database/sqlite/table.py @@ -27,7 +27,7 @@ async def insert(self, fields: Document) -> None: values = tuple(value for value in fields.values() if value is not None) placeholders = ", ".join("?" for _ in values) - sql = f"INSERT INTO {self._table} ({keys}) VALUES ({placeholders})" + sql = f"INSERT OR IGNORE INTO {self._table} ({keys}) VALUES ({placeholders})" await logger.adebug("Inserting into table %s: %s", self._table, fields)