go-mocket icon indicating copy to clipboard operation
go-mocket copied to clipboard

Support Upsert in postgres

Open ZaneZ opened this issue 5 years ago • 0 comments

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.

  1. detect whether there is a update followed by insert

  2. instead of checking command using first word, do a backward search of the key words lists.

ZaneZ avatar Dec 14 '19 01:12 ZaneZ