Skip to content

Releases: piccolo-orm/piccolo_api

0.32.0

02 Jan 18:11

Choose a tag to compare

Added support for the Content-Range HTTP header in the GET endpoint of PiccoloCRUD. This means the API client can fetch the number of available rows, without doing a separate API call to the count endpoint.

GET /?__range_header=true

If the page size is 10, then the response header looks something like:

Content-Range: movie 0-9/100

The feature was created to make Piccolo APIs work better with front ends like React Admin.

Thanks to @trondhindenes for adding this feature, and @sinisaos for help reviewing.

0.31.0

30 Dec 15:03

Choose a tag to compare

Added hooks to PiccoloCRUD. This allows the user to add their own logic before a save / patch / delete (courtesy @trondhindenes).

For example:

# Normal functions and async functions are supported:
def pre_save_hook(movie):
    movie.rating = 90
    return movie

PiccoloCRUD(
    table=Movie,
    read_only=False,
    hooks=[
        Hook(hook_type=HookType.pre_save, callable=pre_save_hook)
    ]
)

0.30.1

13 Dec 19:46

Choose a tag to compare

  • Streamlined the CSRFMiddleware code, and added missing type annotations.
  • If using the __visible_fields parameter with PiccoloCRUD, and the field name is unrecognised, the error response will list the correct field names.
  • Improved test coverage (courtesy @sinisaos).

0.30.0

09 Dec 22:38

Choose a tag to compare

We recently added the __visible_fields GET parameter to PiccoloCRUD, which allows the user to determine which fields are returned by the API.

GET /?__visible_fields=id,name

However, there was no way of the user knowing which fields were supported. This is now possible by visiting the /schema endpoint, which has a visible_fields_options field which lists the columns available on the table and related tables (courtesy @sinisaos).

0.29.2

09 Dec 10:41

Choose a tag to compare

Fixed a bug with the OpenAPI docs when using Array columns. Thanks to @gmos for reporting this issue, and @sinisaos for fixing it.

You now get a nice UI for Array columns:

145380504-cd9fa853-45c7-475b-a1a5-2f1521e7b252

0.29.1

04 Dec 08:40

Choose a tag to compare

The __visible_fields filter on PiccoloCRUD now works on the detail endpoint (courtesy @sinisaos). For example:

GET /1/?__visible_fields=id,name,director.name

We also modified a type annotation in FastAPIWrapper, so you can use it with FastAPI's APIRouter without getting a type warning. Thanks to @gmos for reporting this issue.

0.29.0

16 Nov 07:08

Choose a tag to compare

Added a __visible_fields filter to PiccoloCRUD. It's a very powerful feature which lets us specify which fields we want the API to return from a GET request (courtesy @sinisaos).

It can even support joins, but we must supply a max_joins parameter:

app = PiccoloCRUD(Movie, max_joins=1)
uvicorn(app)

Then we can do:

GET /?__visible_fields=id,name,director.name

Which will return:

  {
    "rows": [
        {
            "id": 17,
            "name": "The Hobbit: The Battle of the Five Armies",
            "director": {
                "name": "Peter Jackson"
            }
        },
        ...
    ]
  }

By specifying exactly which data we want returned, it is much more efficient, especially when fetching large numbers of rows, or with tables with lots of columns.

0.28.1

11 Nov 17:39

Choose a tag to compare

Fixed a bug with the delete endpoint of PiccoloCRUD. It was returning a 204 response with a body (this isn't allowed, and could cause an exception to be raised in the web server). Thanks to @trondhindenes for reporting this issue.

Updated Swagger UI to the latest version.

0.28.0

31 Oct 17:34

Choose a tag to compare

Modified the get_ids endpoint of PiccoloCRUD, so it accepts an offset query parameter. It already supported limit.

0.27.0

24 Oct 20:24

Choose a tag to compare

You can now pass a schema_extra argument to PiccoloCRUD, which is added to the underlying Pydantic schema.

This is mostly to support new Piccolo Admin features.