File tree Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ TaskModelOut: t.Any = create_pydantic_model(
31
31
@app.get (" /tasks/" , response_model = t.List[TaskModelOut])
32
32
async def tasks (
33
33
request : Request,
34
- __cursor : str ,
34
+ __cursor : t.Optional[ str ] = None ,
35
35
__previous : t.Optional[str ] = None ,
36
36
):
37
37
try :
@@ -50,7 +50,9 @@ async def tasks(
50
50
)
51
51
except KeyError :
52
52
paginator = CursorPagination(cursor = __cursor)
53
- rows_result, headers_result = await paginator.get_cursor_rows(Task, request)
53
+ rows_result, headers_result = await paginator.get_cursor_rows(
54
+ Task, request
55
+ )
54
56
rows = await rows_result.run()
55
57
headers = headers_result
56
58
response = JSONResponse(
Original file line number Diff line number Diff line change 41
41
@app .get ("/tasks/" , response_model = t .List [TaskModelOut ])
42
42
async def tasks (
43
43
request : Request ,
44
- __cursor : str ,
44
+ __cursor : t . Optional [ str ] = None ,
45
45
__previous : t .Optional [str ] = None ,
46
46
):
47
47
try :
Original file line number Diff line number Diff line change @@ -135,10 +135,10 @@ def encode_cursor(self, cursor: str) -> str:
135
135
return base64_bytes .decode ("ascii" )
136
136
137
137
async def decode_cursor (self , cursor : str , table : t .Type [Table ]) -> int :
138
+ if cursor is None :
139
+ cursor = ""
138
140
base64_bytes = cursor .encode ("ascii" )
139
141
cursor_bytes = base64 .b64decode (base64_bytes )
140
- # we provide initial cursor like this because
141
- # we cannot pass empty string to FastAPI openapi
142
142
initial_cursor = await (
143
143
table .select ()
144
144
.order_by (table ._meta .primary_key , ascending = False )
You can’t perform that action at this time.
0 commit comments