go-mocket
go-mocket copied to clipboard
Support Upsert in postgres
The statment of UPSERT in postgres:
INSERT INTO ... ON CONFLICT ON CONSTRAINT DO UPDATE ...
Currently in
https://github.com/Selvatico/go-mocket/blob/master/stmt.go#L16, command only takes in first word.
And for INSERT Case, there is only RowsAffected = 1 option if do not identify the error. https://github.com/Selvatico/go-mocket/blob/master/stmt.go#L86
Proposed solution, one of the two will work for postgres.
-
detect whether there is a update followed by insert
-
instead of checking command using first word, do a backward search of the key words lists.