Search code examples
ruby-on-railsrubyrubygemsupsert

PG::UndefinedColumn (ERROR: column d.adsrc does not exist) when using upsert gem


I am currently using the Upsert gem for various operations in my project. Specifically, I rely on Upsert.batch in multiple places. Recently, I attempted to upgrade my PostgreSQL version to 15. However, it seems that Upsert doesn't work with PostgreSQL 15 because the "d.adsrc" column, which is used by Upsert, doesn't exist in PostgreSQL versions starting from 12.

According to the Upsert gem documentation, it should still be compatible with PostgreSQL 12, and I assumed it would work with PostgreSQL 15 as well. I've already updated the Upsert gem to version 2.9.9 and also updated the pg gem to the latest version, but I'm still encountering issues.

Do you have any suggestions or insights on how to make Upsert work with PostgreSQL 15 in this scenario? I'd prefer to avoid upgrading to Rails 6 for now if possible.


Solution

  • You're not on the latest version, from what I can see the adsrc fix for pg12+ was pushed out in 2.9.10.

    Update post comment...

    Looks like actually there was an inadvertent regression of the change that put adsrc back into the codebase just before 2.9.10 was pushed, and that wasn't fixed until e69104e which was not deployed as a gem version.

    So I'd use that version instead:

    gem "upsert", github: "seamusabshere/upsert", ref: "e69104e"
    

    Protip: I'd actually fork the project to my own repo and reference that, so I know it's never going away.