0

I am extracting a series of strings from an XML stream and storing them in a mySQL Database (tried with VARCHAR and TEXT). At the start of each array, in the DB, I get --- and then either a [] if it is a blank array or the values.

Rake task code:

@issue = Array.new  
items.each do |item| #items is the parsed elements from XML
    link_key = item.xpath('key').inner_text
    @issue << link_key
    Rails.logger.debug("Issue: #{@issue.inspect}")
  end

Database value example:

"--- []"

-or-

"--- - CR-3528"

Not sure what else would be useful.

1 Answer 1

3

That's because you're serializing an array.

One way to deal with this is to mark a field as serialized with serialize (docs):

serialize :issue

See this for additional details.

If you had been storing the value as text, you should not have seen this--it would have been just the text.

Sign up to request clarification or add additional context in comments.

2 Comments

Well bust my buffers and steal my chocolate. Thanks!
@ScottJShea Heh ;) Those guys thought of everything. Sometimes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.