Skip to content

Releases: piccolo-orm/piccolo_api

0.24.0

30 Aug 10:51
Compare
Choose a tag to compare

Added support for nested models in create_pydantic_model. For each ForeignKey in the Piccolo table, the Pydantic model will contain a sub model for the related table.

For example:

class Manager(Table):
    name = Varchar()

class Band(Table):
    name = Varchar()
    manager = ForeignKey(Manager)

BandModel = create_pydantic_model(Band, nested=True)

If we were to write BandModel by hand instead, it would look like this:

class ManagerModel(BaseModel):
    name: str

class BandModel(BaseModel):
    name: str
    manager: ManagerModel

This feature is designed to work with the new nested output option in Piccolo >= 0.40.0, which returns the data in the correct format to pass directly to the nested Pydantic model.

band = Band.select(
    Band.id,
    Band.name,
    *Band.manager.all_columns()
).first(
).output(
    nested=True
).run_sync()
>>> print(band)
{'id': 1, 'name': 'Pythonistas', 'manager': {'id': 1, 'name': 'Guido'}}

BandModel(**band)

Courtesy @aminalaee.

0.23.1

13 Aug 21:33
Compare
Choose a tag to compare

Make sure asyncpg gets installed, as Piccolo API currently has a hard requirement on it (we hope to fix this in the future).

0.23.0

13 Aug 20:16
Compare
Choose a tag to compare
  • Fixed MyPy errors (courtesy @sinisaos).
  • Simplification of JWT authentication - it no longer needlessly checks expiry, as PyJWT already does this (courtesy @aminalaee).
  • Substantial increase in code coverage (courtesy @aminalaee and @sinisaos).
  • Increased the minimum PyJWT version, as versions > 2.0.0 return the JWT as a string instead of bytes.
  • Added an option to exclude columns when using create_pydantic_model (courtesy @kucera-lukas).

0.22.0

06 Aug 14:26
Compare
Choose a tag to compare

Updating PiccoloCRUD so it works better with the custom primary key feature added in Piccolo.