Skip to content

Newly added dimension field makes deserialization of 1.6.0 array field on 1.5.9 raise #652

@Earlopain

Description

@Earlopain

Ref: rails/rails#55423

The deserialization code blindy tries to put each key-value pair into a writer method:

ruby-pg/lib/pg/coder.rb

Lines 17 to 23 in b77e86c

def initialize(hash=nil, **kwargs)
warn("PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}", category: :deprecated) if hash
(hash || kwargs).each do |key, val|
send("#{key}=", val)
end
end

Since older versions don't have the dimension, trying to assign to it fails. I wonder if the code should be more careful with that and rescue NameError or similar. Would that make sense?

This is in the context of a rails app where rolling deploys are happening. Apps with the new code cache the new dimension field and older apps that haven't been rotated yet will fail to read it. Rails actually discourages caching full models for similar reasons but people tend to do so anyways since it works 99.99% of the time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions