Skip to content

Properly serialize postgres array columns - #82

Merged
westonganger merged 3 commits into
westonganger:masterfrom
lucasbiguet:master
Jul 18, 2026
Merged

Properly serialize postgres array columns#82
westonganger merged 3 commits into
westonganger:masterfrom
lucasbiguet:master

Conversation

@lucasbiguet

@lucasbiguet lucasbiguet commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

I ran into a bug with a PG enum array column: for those, attributes_for_database return a struct:

 "target_sizes" => #<struct ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array::Data encoder=#<PG::TextEncoder::Array:0x000000012ca44e08 "enum[]"  elements_type=nil needs quotation>, values=["XS","S"]>

which got serialized by build_snapshot_item as:

[["name => enum[]", " elements_type => nil"], " values => [XS", " S]"]

It should just serialize the values as a standard array: ["XS","S"]

The PR includes a test to catch that bug, and I tried to keep the fix as minimal as possible, hope this looks good but if not feel free to suggest changes !

@westonganger westonganger left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments/questions that I will wait for you to respond to, but other than that this looks good. Thanks.

Comment thread lib/active_snapshot/models/snapshot.rb
Comment thread lib/active_snapshot/models/snapshot.rb
Comment thread CHANGELOG.md Outdated
@lucasbiguet

Copy link
Copy Markdown
Contributor Author

@westonganger I addressed your comments if you want to take a look

@westonganger
westonganger merged commit 3c86401 into westonganger:master Jul 18, 2026
20 checks passed
@westonganger

Copy link
Copy Markdown
Owner

Merged. Thanks for your contribution!

@westonganger westonganger changed the title Properly serialize PG enum array columns Properly serialize postgres array columns Jul 18, 2026
@westonganger

Copy link
Copy Markdown
Owner

v1.2.1 is now released which contains this fix.

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

Successfully merging this pull request may close these issues.

2 participants