|
| 1 | +# Python version support |
| 2 | + |
| 3 | +Now the minimum supported Python version is `3.9`. |
| 4 | + |
| 5 | +# API Changes |
| 6 | + |
| 7 | +## `create_page` |
| 8 | + |
| 9 | +`create_page` function no longer accepts `total` and `params` arguments as positional. |
| 10 | +Instead, it accepts `total` and `params` as keyword arguments. |
| 11 | + |
| 12 | +## `Page.create` |
| 13 | + |
| 14 | +`Page.create` class method signature was changed. Now it accepts `total` only as a keyword argument. |
| 15 | +It was changed because `total` is no longer a required argument and can be omitted in some cases. |
| 16 | + |
| 17 | +New signature now looks like this: |
| 18 | +```python |
| 19 | + @classmethod |
| 20 | + def create( |
| 21 | + cls, |
| 22 | + items: Sequence[T], |
| 23 | + params: AbstractParams, |
| 24 | + **kwargs: Any, |
| 25 | + ) -> Self: |
| 26 | + pass |
| 27 | +``` |
| 28 | + |
| 29 | +## `Page.with_params`/`Page.with_custom_options` |
| 30 | + |
| 31 | +`Page.with_params` and `Page.with_custom_options` class methods where removed. |
| 32 | +Now you need to use `CustomizedPage` class to create a new page object with custom options. |
| 33 | + |
| 34 | +`Page.with_params` migration: |
| 35 | +```python |
| 36 | +from typing import TypeVar |
| 37 | + |
| 38 | +from fastapi_pagination import Page, Params |
| 39 | +from fastapi_pagination.customization import CustomizedPage, UseParams |
| 40 | + |
| 41 | +T = TypeVar("T") |
| 42 | + |
| 43 | +class MyParams(Params): |
| 44 | + ... |
| 45 | + |
| 46 | +# CustomPage = Page.with_params(MyParams) |
| 47 | +CustomPage = CustomizedPage[ |
| 48 | + Page[T], |
| 49 | + UseParams(MyParams), |
| 50 | +] |
| 51 | +``` |
| 52 | + |
| 53 | +`Page.with_custom_options` migration: |
| 54 | +```python |
| 55 | +from typing import TypeVar |
| 56 | + |
| 57 | +from fastapi import Query |
| 58 | + |
| 59 | +from fastapi_pagination import Page |
| 60 | +from fastapi_pagination.customization import CustomizedPage, UseParamsFields |
| 61 | + |
| 62 | +T = TypeVar("T") |
| 63 | + |
| 64 | +# CustomPage = Page.with_custom_options(size=Query(100, ge=1, le=1000)) |
| 65 | +CustomPage = CustomizedPage[ |
| 66 | + Page[T], |
| 67 | + UseParamsFields(size=Query(100, ge=1, le=1000)), |
| 68 | +] |
| 69 | +``` |
| 70 | + |
| 71 | +`cls_name`, `module` args migration: |
| 72 | +```python |
| 73 | +from typing import TypeVar |
| 74 | + |
| 75 | +from fastapi import Query |
| 76 | + |
| 77 | +from fastapi_pagination import Page |
| 78 | +from fastapi_pagination.customization import CustomizedPage, UseName, UseModule, UseParamsFields |
| 79 | + |
| 80 | +T = TypeVar("T") |
| 81 | + |
| 82 | +# CustomPage = Page.with_custom_options( |
| 83 | +# size=Query(100, ge=1, le=1000), |
| 84 | +# cls_name="CustomPage", |
| 85 | +# module="my_module" |
| 86 | +# ) |
| 87 | +CustomPage = CustomizedPage[ |
| 88 | + Page[T], |
| 89 | + UseName("CustomPage"), |
| 90 | + UseModule("my_module"), |
| 91 | + UseParamsFields(size=Query(100, ge=1, le=1000)), |
| 92 | +] |
| 93 | +``` |
| 94 | + |
| 95 | +## `OptionalParams`/`OptionalLimitOffsetParams` |
| 96 | + |
| 97 | +`OptionalParams`/`OptionalLimitOffsetParams` classes were removed. Now you need to use `UseOptionalParams` customization: |
| 98 | + |
| 99 | +```python |
| 100 | +from typing import TypeVar |
| 101 | + |
| 102 | +from fastapi_pagination import Page |
| 103 | +from fastapi_pagination.customization import CustomizedPage, UseOptionalParams |
| 104 | + |
| 105 | +T = TypeVar("T") |
| 106 | + |
| 107 | +CustomPage = CustomizedPage[ |
| 108 | + Page[T], |
| 109 | + UseOptionalParams(), |
| 110 | +] |
| 111 | +``` |
| 112 | + |
| 113 | +# Extension Changes |
| 114 | + |
| 115 | +## `fastapi_pagination.ext.sqlalchemy` |
| 116 | + |
| 117 | +`paginate_query` function was removed. Now you need to use `create_paginate_query` function: |
| 118 | + |
| 119 | +```python |
| 120 | +from fastapi_pagination.ext.sqlalchemy import create_paginate_query |
| 121 | +``` |
| 122 | + |
| 123 | +# Removed modules |
| 124 | + |
| 125 | +The following modules have been removed from the library: |
| 126 | + |
| 127 | +* `fastapi_pagination.ext.async_sqlalchemy` |
| 128 | +* `fastapi_pagination.ext.sqlalchemy_future` |
| 129 | +* `fastapi_pagination.ext.async_sqlmodel` |
| 130 | + |
| 131 | +If you were using any of these modules, you will need to update your code to use the `fastapi_pagination.ext.sqlalchemy` module |
| 132 | +for SQLAlchemy and `fastapi_pagination.ext.sqlmodel` module for SQLModel. |
0 commit comments