little_pger icon indicating copy to clipboard operation
little_pger copied to clipboard

upsert does not support composite primary keys

Open Gittenburg opened this issue 5 years ago • 2 comments

If we have a table with a composite primary key:

CREATE TABLE items (
	x INT,
	y INT,
        value INT,
	PRIMARY KEY (x, y)
);

pg.upsert('items', values={'x': 1, 'y': 2, 'value': 44}) leads to the following error:

there is no unique or exclusion constraint matching the ON CONFLICT specification

because _real_upsert just fetches one primary key.

Gittenburg avatar Nov 29 '19 19:11 Gittenburg

I'm sorry, for some reason I didn't see any notification for your issue. Are you still using the library, and would that feature make your life simpler and better (in a small way of course)? If so, I'd be happy to implement it!

cjauvin avatar Mar 02 '20 21:03 cjauvin

Yeah GitHub notifications are weird. I have since moved on to use my own little Postgres helper methods, so I no longer personally need this feature ... thanks for the offer anyway!

Gittenburg avatar Mar 03 '20 16:03 Gittenburg