Releases: piccolo-orm/piccolo
Release list
0.38.1
Minor changes to get_or_create to make sure it handles joins correctly.
instance = (
Band.objects()
.get_or_create(
(Band.name == "My new band")
& (Band.manager.name == "Excellent manager")
)
.run_sync()
)In this situation, there are two columns called 'name' - we need to make sure the correct value is applied if the row doesn't exist.
0.38.0
get_or_create now supports more complex where clauses. For example:
row = await Band.objects().get_or_create(
(Band.name == 'Pythonistas') & (Band.popularity == 1000)
).run()And you can find out whether the row was created or not using row._was_created.
Thanks to @wmshort for reporting this issue.
0.37.0
Added ModelBuilder, which can be used to generate data for tests (courtesy @aminalaee).
0.36.0
Fixed an issue where like and ilike clauses required a wildcard (%). For example:
await Manager.select().where(Manager.name.ilike('Guido%')).run()You can now omit wildcards if you like:
await Manager.select().where(Manager.name.ilike('Guido')).run()Which would match on 'guido' and 'Guido', but not 'Guidoxyz'.
Thanks to @wmshort for reporting this issue.
0.35.0
- Improved
PrimaryKeydeprecation warning (courtesy @tonybaloney). - Added
piccolo schema generatewhich creates a Piccolo schema from an existing database. - Added
piccolo tester runwhich is a wrapper around pytest, and temporarily setsPICCOLO_CONF, so a test database is used. - Added the
getconvenience method (courtesy @aminalaee). It returns the first matching record, orNoneif there's no match. For example:
manager = await Manager.objects().get(Manager.name == 'Guido').run()
# This is equivalent to:
manager = await Manager.objects().where(Manager.name == 'Guido').first().run()0.34.0
Added the get_or_create convenience method (courtesy @aminalaee). Example usage:
manager = await Manager.objects().get_or_create(
Manager.name == 'Guido'
).run()0.33.1
- Bug fix, where
compare_dictswas failing in migrations if anyColumnhad an unhashable type as an argument. For example:Array(default=[]). Thanks to @hipertracker for reporting this problem. - Increased the minimum version of orjson, so binaries are available for Macs running on Apple silicon (courtesy @hipertracker).
0.33.0
Fix for auto migrations when using custom primary keys (thanks to @adriangb and @aminalaee for investigating this issue).
0.32.0
Migrations can now have a description, which is shown when using piccolo migrations check. This makes migrations easier to identify (thanks to @davidolrik for the idea).
0.31.0
Added an all_columns method, to make it easier to retrieve all related columns when doing a join. For example:
await Band.select(Band.name, *Band.manager.all_columns()).first().run()Changed the instructions for installing additional dependencies, so they're wrapped in quotes, to make sure it works on ZSH (i.e.
pip install 'piccolo[postgres]' instead of pip install piccolo[postgres]).