Publ: Development Blog

v0.3.2: a smol bugfix release

Posted (3 years ago)

I found a few more annoying bugs that were shaken out from the whole PonyORM transition, as well as a couple of bugs in the new shape functionality. There’s probably a few more of these bugs lurking in the codebase (I mean, in addition to the existing bugs I know about), but here’s what’s changed:

That last one is something where there’s probably a few other lurking similar things in the codebase; peewee allows you to check for the existence of any matching record with:

record = ModelClass.get(key=value)
if record:
    # a record exists

which happens to also be a valid expression in PonyORM (one of the few places where they have API in common), but PonyORM only lets you use get to retrieve a single value. In PonyORM you instead have to do something a bit different to see if any item matches; for example, this is what Publ does now:

if for e in ModelClass if e.key == value).exists():
    # a record exists

which happens to be somewhat more efficient (although it’s basically a micro-optimization).

I suppose I should simply audit all uses of .get() since most of them are for single-item lookups but there’s probably a few places where I’m using it as a rough .exists() equivalent, which was never really great anyway.