Skip to content

Conversation

@zealot128
Copy link

@zealot128 zealot128 commented Oct 29, 2019

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...

@jakeonfire
Copy link
Member

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

@zealot128
Copy link
Author

@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.

@jakeonfire
Copy link
Member

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.

- Ignore virtual attributes (ActsAsTaggable...) on serialization
@jakeonfire
Copy link
Member

fyi

Failures:

  1) Polo::Adapters::Postgres#on_duplicate_key_update should raise an error
     Failure/Error: expect { adapter.on_duplicate_key_update(double(), double()) }.to raise_error('on_duplicate: :override is not currently supported in the PostgreSQL adapter')
     
       expected Exception with "on_duplicate: :override is not currently supported in the PostgreSQL adapter", got #<ActiveRecord::StatementInvalid: SQLite3::SQLException: no such function: version: SELECT version()> with backtrace:
         # ./lib/polo/adapters/postgres.rb:5:in `on_duplicate_key_update'
         # ./spec/adapters/postgres_spec.rb:19:in `block (4 levels) in <top (required)>'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants