Description
It'd be more flexible and simpler to pass to postgres the list of columns or index name itself. But I guess you'd want to continue supporting the old way, too, so it wouldn't actually simplify anything.
I noticed this while adding something similar in telsasoft-specific db layer. We use unique indexes but not primary keys. There may be other reasons why we wouldn't use DB.insert(), too, but it'd be nice if this supported non-primary keys, and also multiple combinations of unique indexes.
Edit: of course I mean DB.upsert()
Edit: also, ON CONFLICT DO NOTHING needs no pkey nor columns nor unique index at all (even though in my experience that may be a bad idea since if an unique index is missing it causes no error)
Edit: also, ON CONFLICT allows WHERE clauses in two different places (in the ON CONFLICT and in the DO UPDATE SET). And some other syntactic cases. But, I'm actually using the where clauses now, but some of these are maybe "pie in the sky" and maybe of maybe marginal value.
Activity
Add keyname parameter to update(), delete() and upsert() (#56)
Cito commentedon Nov 22, 2026
DB.upsert(),DB.update()andDB.delete()now have an optionalkeynameparameter likeDB.get()(#127, in 6.3). It is a column name or a sequence of names, so these methods also work for tables without a primary key. Forupsert()it is the conflict target.ON CONFLICT DO NOTHINGwithout a target, constraint names andWHEREclauses are not supported. The awkward use of keyword arguments in these methods is discussed for 7.0 in #126.