DavyJonesLocker / postgres_ext-serializers

MIT License
324 stars 30 forks source link

PG::DuplicateAlias error when calling to_json multiple times #51

Closed felixbuenemann closed 8 years ago

felixbuenemann commented 8 years ago

If the to_json method is called multiple times on an ActiveModel::ArraySerializer, ActiveRecord throws a PG::DuplicateAlias error, because the internal state is not cleaned up.

Proposed Fix: Extract the instance variables set in initialize into a reset method and call it at the beginning of _postgres_serializable_array.

felixbuenemann commented 8 years ago

I've already got a fix for this in the works (see felixbuenemann/postgres_ext-serializers@f75ae0e), but it's currently based on top of #50 so it either needs to wait or requires rebasing. It also wouldn't hurt to add a test that calls to_json at least twice.