zdennis/activerecord-import

alias_attribute causing "specified more than once" error upon import.

skunkworker opened this issue · 7 comments

Related to #799 and #728

In my model I am aliasing an attribute, when I try to import a record from an existing record, the INSERT INTO sql string has the aliased column name twice instead of once.

Rails 6.1.7.6
activerecord-import v1.5.0

The ActiveRecord Schema cache is also being used.

Eg:

class Foobar < ApplicationRecord
  alias_attribute :myname, :name
end

Foobar.import(other_record)
=> 
ActiveRecord::JDBCError: org.postgresql.util.PSQLException: ERROR: column "name" specified more than once

@leonidkroka any ideas how to resolve this issue?

Just to add more context, this seems specific to JRuby and PostgreSQL. I've added JRuby 9.4/AR 7 and 9.3/AR6 6.1 to the CI tests and they are passing 🤔

@skunkworker what version of activerecord-jdbcpostgresql-adapter gem do you have installed?

@jkowens activerecord-jdbcpostgresql-adapter (61.2-java) We haven't moved to 9.4 yet because it's not stable enough for production use.

@skunkworker I have jruby back in the CI, could you possibly create a PR with a failing test to demonstrate the issue?

@jkowens #817 I was able to reproduce this with jruby and MRI, the issue appears to occur when you have an alias_attribute :new_col, :old_col where both columns are currently being backed in the database.