Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
skunkworker opened this issue Aug 30, 2023 · 7 comments
Open

Comments

@skunkworker
Copy link

skunkworker commented Aug 30, 2023

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
@jkowens
Copy link
Collaborator

jkowens commented Aug 30, 2023

@leonidkroka any ideas how to resolve this issue?

@jkowens
Copy link
Collaborator

jkowens commented Sep 3, 2023

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 🤔

@jkowens
Copy link
Collaborator

jkowens commented Sep 3, 2023

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

@skunkworker
Copy link
Author

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

@jkowens
Copy link
Collaborator

jkowens commented Sep 6, 2023

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

@skunkworker
Copy link
Author

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

@rsanheim
Copy link

This is happening in our rails 6.1 app with mysql 8.0 as well, so I think this bug is not limited to any particular DB adapter.

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

No branches or pull requests

3 participants