Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On update, existing node values destroyed if not present in update attributes #9

Open
alank64 opened this issue Apr 24, 2013 · 0 comments

Comments

@alank64
Copy link

alank64 commented Apr 24, 2013

When performing an update, due to Neo4j's REST API PUT request, the node values are not preserved if not present in the update values. Nothing we can do about that one, but my guess is that keymaker is attempting to insert all the property values of the class but given the code:

def process_attrs(attrs)
    attrs = attrs.symbolize_keys
    self.class.properties.delete_if{|p| p == :node_id}.each do |property|
      if property == :active_record_id
        process_attr(property, attrs[:id].present? ? attrs[:id] : attrs[:active_record_id])
      else
        process_attr(property, attrs[property])
      end
    end
  end

it would set the property to nil if not present in the attrs passed (process_attr(property, attrs[property])). Therefore probably a change to the following:

def process_attrs(attrs)
    attrs = attrs.symbolize_keys
    self.class.properties.delete_if{|p| p == :node_id}.each do |property|
      if property == :active_record_id
        process_attr(property, attrs[:id].present? ? attrs[:id] : attrs[:active_record_id])
      else
        if attrs[property]
          process_attr(property, attrs[property])
        end
      end
    end
  end

this at least inserts current values and replaces current values defined in the passed attrs.

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

No branches or pull requests

1 participant