DavyJonesLocker / postgres_ext-serializers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DuplicateAlias error

mcm-ham opened this issue · comments

If I serialize a class like:

class Offer < ActiveRecord::Base
  belongs_to :created_by, class_name: 'User', inverse_of: :offers
  belongs_to :reviewed_by, class_name: 'User', inverse_of: :reviewed_offers
end

Or

class Offer < ActiveRecord::Base
  belongs_to :user
  has_many :items
end

class Item < ActiveRecord::Base
  belongs_to :user 
end

Then it produces two CTE called users_attributes_filter which throws a PG DuplicateAlias error.

Note #23 didn't completely fix it since you can have multiple relationname_foreignkeyname_attributes_filter with different containing tables so have changed approach to keep a cache of names and simply add an incrementing number if name already exists crossroads@89ccd2b

Fix from crossroads repo merged in PR #38.