This is part of the CRUD API in API. Actually I don't feel that "get" is
such a bad choice here. The HTTP verb is also GET. Yes, it's a bit
confusing that we deal with dicts and "get" is also a dict method. But
then we would also need to change "update".
Talking about these methods, there are other things about the API that I
really would do differently today. Particularly the signature of the
methods is kind of awkward, overloaded too much (not playing well with
type hints) and not always consistent between the methods.
Also, returning a dict and at the same time mutating it is not pythonic.
For example, the dict.update() method mutates a dict, but returns None,
not the mutated object like our methods do. Maybe data classes would
also be better than dicts for these methods.
But remember that this API was created when we didn't have type hints,
data classes (not even named tuples) and still used OIDs in Postgres.
The API made a lot more sense when OIDs were contained in the dicts and
PKs did not need to be passed as params.
On 27.02.26 15:12, D'Arcy Cain wrote:
> I made a mistake. It was a long time ago when I first created PyGreSQL
> (PyGres95 back then). When I wanted a method to get one entry from a
> table using the primary key I called it "get". That was pretty stupid
> in retrospect. That name conflicts with dict methods. I don't know
> about others but I like to combine the DB class with dict and that makes
> it hard.
>
> I think that we should get rid of that and find a better name. I like
> "select" as it is closer to the SQL statement that get is based on.
>
> Obviously we can't just change something like this overnight but what do
> others think about this in theory? If it makes sense we could add the
> new name as an alias for get now and deprecate get over a long period of
> time.
>
> Of course, this is easily worked around with a sub-class but I really
> feel that get is a wart that needs to be excised.
>
> Cheers.
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo/pygresql