polo icon indicating copy to clipboard operation
polo copied to clipboard

Preliminary pg upsert support

Open zealot128 opened this issue 5 years ago • 3 comments

Implemented two ways,

1. "naive upsert" for pg < 9.5

insert into, on exception update all the things.

2. real upsert since 9.5

INSERT INTO .... ON CONFLICT id DO UPDATE SET ...

Also included a fix for exporting ActsAsTaggableOn - AATO adds it's own "tag_list" as a virtual attribute into the record.attributes, thus, is included in the "INSERT" statement.

The ac88b32 fixes that problem by comparing the attributes with column_names.


Would be nice if some user PG user would test it...

zealot128 avatar Oct 29 '19 08:10 zealot128

@zealot128 if you wouldn't mind rebasing master and getting a green build, we can finally merge this 😅

jakeonfire avatar Apr 22 '20 21:04 jakeonfire

@zealot128 if you wouldn't mind rebasing master and getting a green build, we can finally merge this 😅

Squashed rebase is pushed. Let me know if there are any other issues.

zealot128 avatar Apr 23 '20 07:04 zealot128

looks like there is one legitimate exception:

expect { adapter.on_duplicate_key_update(double(), double()) }.to raise_error('on_duplicate: :override is not currently supported in the PostgreSQL adapter')

makes sense. can you fix the spec? otherwise i may be able to help at some point.

jakeonfire avatar Apr 23 '20 18:04 jakeonfire