Closed lauraannwilliams closed 6 years ago
I added a couple of virtual fields to a record in rails 5.1. using the attribute api
attribute :use_default, :boolean, default: false
And now when I try to upsert, it's trying to set those values and I get a sql error
PG::UndefinedColumn - ERROR: column "use_default" of relation "translations" does not exist
I think it's due to this line https://github.com/jesjos/active_record_upsert/blob/bed144dd2b39354593a353a3cc1d43d5d978db12/lib/active_record_upsert/compatibility/rails51.rb#L5
self.attributes returns both virtual and database attributes. I'm not sure how to filter those out, perhaps using column_for_attribute
self.attributes
Good report!
Yes, the Attributes API would get issues, so I support getting a fix for this.
Do you feel up to offering a PR? It doesn’t matter if it’s not perfect from the start.
I added a couple of virtual fields to a record in rails 5.1. using the attribute api
attribute :use_default, :boolean, default: false
And now when I try to upsert, it's trying to set those values and I get a sql error
PG::UndefinedColumn - ERROR: column "use_default" of relation "translations" does not exist
I think it's due to this line https://github.com/jesjos/active_record_upsert/blob/bed144dd2b39354593a353a3cc1d43d5d978db12/lib/active_record_upsert/compatibility/rails51.rb#L5
self.attributes
returns both virtual and database attributes. I'm not sure how to filter those out, perhaps using column_for_attribute