Skip to content

Releases: piccolo-orm/piccolo

0.46.0

14 Sep 08:25
Compare
Choose a tag to compare

Added the fixtures app. This is used to dump data from a database to a JSON file, and then reload it again. It's useful for seeding a database with essential data, whether that's a colleague setting up their local environment, or deploying to production.

To create a fixture:

piccolo fixtures dump --apps=blog > fixture.json

To load a fixture:

piccolo fixtures load fixture.json

As part of this change, Piccolo's Pydantic support was brought into this library (prior to this it only existed within the piccolo_api library). At a later date, the piccolo_api library will be updated, so it's Pydantic code just proxies to what's within the main piccolo library.

0.45.1

10 Sep 16:37
Compare
Choose a tag to compare

Improvements to piccolo schema generate. It's now smarter about which imports to include. Also, the Table classes output will now be sorted based on their ForeignKey columns. Internally the sorting algorithm has been changed to use the graphlib module, which was added in Python 3.9.

0.45.0

09 Sep 11:11
Compare
Choose a tag to compare

Added the piccolo schema graph command for visualising your database structure, which outputs a Graphviz file. It can then be turned into an image, for example:

piccolo schema map | dot -Tpdf -o graph.pdf

Also made some minor changes to the ASGI templates, to reduce MyPy errors.

0.44.1

08 Sep 11:51
Compare
Choose a tag to compare

Updated to_dict so it works with nested objects, as introduced by the prefetch functionality in v0.44.0

For example:

band = Band.objects(Band.manager).first().run_sync()

>>> band.to_dict()
{'id': 1, 'name': 'Pythonistas', 'manager': {'id': 1, 'name': 'Guido'}}

It also works with filtering:

>>> band.to_dict(Band.name, Band.manager.name)
{'name': 'Pythonistas', 'manager': {'name': 'Guido'}}

0.44.0

07 Sep 18:38
Compare
Choose a tag to compare

Added the ability to prefetch related objects. Here's an example:

band = await Band.objects(Band.manager).run()
>>> band.manager
<Manager: 1>

If a table has a lot of ForeignKey columns, there's a useful shortcut, which will return all of the related rows as objects.

concert = await Concert.objects(Concert.all_related()).run()
>>> concert.band_1
<Band: 1>
>>> concert.band_2
<Band: 2>
>>> concert.venue
<Venue: 1>

Thanks to @wmshort for all the input.

0.43.0

02 Sep 09:07
Compare
Choose a tag to compare

Migrations containing Array, JSON and JSONB columns should be more reliable now. More unit tests were added to cover edge cases.

0.42.0

01 Sep 06:40
Compare
Choose a tag to compare

You can now use all_columns at the root. For example:

await Band.select(
    Band.all_columns(),
    Band.manager.all_columns()
).run()

You can also exclude certain columns if you like:

await Band.select(
    Band.all_columns(exclude=[Band.id]),
    Band.manager.all_columns(exclude=[Band.manager.id])
).run()

0.41.1

31 Aug 19:27
Compare
Choose a tag to compare

Fixes a regression where if multiple tables are created in a single migration file, it could potentially fail by applying them in the wrong order.

0.41.0

31 Aug 12:56
Compare
Choose a tag to compare

Fixed a bug where if all_columns was used two or more levels deep, it would fail. Thanks to @wmshort for reporting this issue.

Here's an example:

Concert.select(
    Concert.venue.name,
    *Concert.band_1.manager.all_columns()
).run_sync()

Also, the ColumnsDelegate has now been tweaked, so unpacking of all_columns is optional.

# This now works the same as the code above (we have omitted the *)
Concert.select(
    Concert.venue.name,
    Concert.band_1.manager.all_columns()
).run_sync()

0.40.1

30 Aug 10:09
Compare
Choose a tag to compare

Loosen the typing-extensions requirement, as it was causing issues when installing asyncpg.