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

Your Aws::SdbInterface.query_expression_from_array() not being used #115

Open
pr1001 opened this issue Aug 14, 2012 · 3 comments
Open

Your Aws::SdbInterface.query_expression_from_array() not being used #115

pr1001 opened this issue Aug 14, 2012 · 3 comments

Comments

@pr1001
Copy link

pr1001 commented Aug 14, 2012

I found that IN statements in WHERE clauses were not being expanded correctly. While one one hand this might be seen as an issue in right_aws (and I opened an issue with them), I see that you try to work around it in query_expression_from_array.

However, for the life of me I couldn't figure out why I was getting incorrectly serialized arrays. Copying the exact code from sdb_interface.rb into a patch fixed my problem:

class Aws::SdbInterface
  def query_expression_from_array(params) #:nodoc:
    return '' if Aws::Utils.blank?(params)
    query = params[0].to_s
    i     = 1
    query.gsub(/(\\)?(\?)/) do
      if $1 # if escaped '\?' is found - replace it by '?' without backslash
        "?"
      else # well, if no backslash precedes '?' then replace it by next param from the list
        case params[i]
        when Array
          ret = "(#{params[i].map{|p| escape(p)}.join(",")})"
        else
          ret = escape(params[i])
        end
        i   +=1
        ret
      end
    end
  end
end

This suggests to me that somehow the right_aws method is taking precendence over yours.

@treeder
Copy link
Member

treeder commented Aug 14, 2012

I don't think right_aws and aws are really compatible as aws is a fork of right_aws. You should probably just be using one or the other.

@pr1001
Copy link
Author

pr1001 commented Aug 14, 2012

Oh, ok, right. That being said, I hadn't changed anything but still needed the Aws:SdbInterface code above to get it to work.

@treeder
Copy link
Member

treeder commented Aug 14, 2012

Ok, can you give me a pull request? I'll merge it, then push a new gem release.

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

2 participants