Closed Jaymon closed 3 years ago
So I totally misunderstood what this code was supposed to do. Usually, when we remove the primary key, we do this:
class MyOrm(Orm):
_id = None
and so _id
is always None:
o = MyOrm()
o._id # None
and we want pk
to do the same thing since pk
is treated as special (an alias to the primary key, whatever it's named) in the code, so we want this to work:
o = Orm()
o._id # None
o.pk # None
But since _id
doesn't exist, pk
doesn't exist, and an AttributeError will be raised, so the k != "pk"
just makes sure pk
is treated like _id
we have a line in
__getattr__
like this:It would be better if that line was updated to check all the primary key aliases: