Skip to content

Commit 2c90c34

Browse files
authored
Use deepcopy when copying Piccolo queries (#1677)
1 parent 0ad6d3b commit 2c90c34

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

fastapi_pagination/ext/piccolo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
__all__ = ["apaginate", "paginate"]
22

33
from contextlib import suppress
4-
from copy import copy
4+
from copy import deepcopy
55
from functools import partial
66
from typing import Any, TypeVar, cast
77

@@ -28,7 +28,7 @@ def _copy_query(query: Select[TTable_co]) -> Select[TTable_co]:
2828

2929
for s in select_cls.__slots__:
3030
with suppress(AttributeError):
31-
setattr(q, s, copy(getattr(query, s)))
31+
setattr(q, s, deepcopy(getattr(query, s)))
3232

3333
return q
3434

tests/ext/test_piccolo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from piccolo.table import Table
1111
from pytest_asyncio import fixture as async_fixture
1212

13-
from fastapi_pagination.ext.piccolo import paginate
13+
from fastapi_pagination.ext.piccolo import apaginate
1414
from tests.base import BasePaginationTestSuite
1515
from tests.utils import faker
1616

@@ -33,7 +33,7 @@ def query(request):
3333
if request.param:
3434
return User
3535

36-
return User.select()
36+
return User.select().order_by(User.id)
3737

3838

3939
DB = SQLiteEngine()
@@ -74,6 +74,6 @@ async def entities(self, query, client):
7474
def app(self, builder, query, engine):
7575
@builder.both.default
7676
async def route():
77-
return await paginate(query)
77+
return await apaginate(query)
7878

7979
return builder.build()

0 commit comments

Comments
 (0)