diff --git a/src/simple_sqlite3_orm/_table_spec.py b/src/simple_sqlite3_orm/_table_spec.py index 6469fe3e..61976ea6 100644 --- a/src/simple_sqlite3_orm/_table_spec.py +++ b/src/simple_sqlite3_orm/_table_spec.py @@ -406,18 +406,18 @@ def table_delete_stmt( """ gen_delete_from_stmt = f"DELETE FROM {delete_from}" gen_where_stmt = cls._generate_where_stmt(where_cols, where_stmt) - gen_order_by_stmt = cls._generate_order_by_stmt(order_by, order_by_stmt) - gen_limit_stmt = f"LIMIT {limit}" if limit is not None else "" gen_returning_stmt = cls._generate_returning_stmt( returning_cols, returning_stmt ) + gen_order_by_stmt = cls._generate_order_by_stmt(order_by, order_by_stmt) + gen_limit_stmt = f"LIMIT {limit}" if limit is not None else "" res = gen_sql_stmt( gen_delete_from_stmt, gen_where_stmt, + gen_returning_stmt, gen_order_by_stmt, gen_limit_stmt, - gen_returning_stmt, ) logger.debug(res) return res diff --git a/tests/test_e2e/test_asyncio.py b/tests/test_e2e/test_asyncio.py index 4ff119d7..399df2d2 100644 --- a/tests/test_e2e/test_asyncio.py +++ b/tests/test_e2e/test_asyncio.py @@ -142,6 +142,7 @@ async def test_delete_entries( _res = await async_pool.orm_delete_entries( key_id=entry.key_id, prim_key_sha256hash=entry.prim_key_sha256hash, + _limit=1, ) assert _res == 1 else: @@ -150,6 +151,7 @@ async def test_delete_entries( _returning_cols="*", key_id=entry.key_id, prim_key_sha256hash=entry.prim_key_sha256hash, + _limit=1, ) assert isinstance(_res, list) diff --git a/tests/test_e2e/test_threadpool.py b/tests/test_e2e/test_threadpool.py index 4fc9cac6..410ed2f1 100644 --- a/tests/test_e2e/test_threadpool.py +++ b/tests/test_e2e/test_threadpool.py @@ -125,6 +125,7 @@ def test_delete_entries( _res = thread_pool.orm_delete_entries( key_id=entry.key_id, prim_key_sha256hash=entry.prim_key_sha256hash, + _limit=1, ).result() assert _res == 1 else: @@ -133,6 +134,7 @@ def test_delete_entries( _returning_cols="*", key_id=entry.key_id, prim_key_sha256hash=entry.prim_key_sha256hash, + _limit=1, ).result() assert isinstance(_res, list) diff --git a/tests/test_e2e/test_with_sample_db.py b/tests/test_e2e/test_with_sample_db.py index 1d977001..73f16099 100644 --- a/tests/test_e2e/test_with_sample_db.py +++ b/tests/test_e2e/test_with_sample_db.py @@ -108,6 +108,7 @@ def test_delete_entries( _res = self.orm_inst.orm_delete_entries( key_id=entry.key_id, prim_key_sha256hash=entry.prim_key_sha256hash, + _limit=1, ) assert _res == 1 else: @@ -116,6 +117,7 @@ def test_delete_entries( _returning_cols="*", key_id=entry.key_id, prim_key_sha256hash=entry.prim_key_sha256hash, + _limit=1, ) assert isinstance(_res, Generator)