Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Rack::Utils.build_nested_query with integer values #557

Closed
cyx opened this Issue · 5 comments

5 participants

@cyx

Hi,

Not sure if this is intended behavior, but if you try to use build_nested_query like so:

Rack::Utils.build_nested_query("foo" => 1)
# => "foo"

Rack::Utils.build_nested_query("foo" => { "bar" => 1})
# => "foo[bar]"

It drops the value silently. If you think this is a bug, I can do a pull request or something. Thanks!

@tizoc

+1

Right now I just use my own wrapper to avoid having values silently discarded here, but it would be great if Rack did this check in the body of the else branch:

https://github.com/rack/rack/blob/master/lib/rack/utils.rb#L165

@spastorino
Owner

I agree on this one, I was talking with @raggi about it. I will wait for him just in case.
Anyway you can provide a PR, it's an easy fix and probably better for James to follow.

I did an sketch fix here https://gist.github.com/spastorino/7375c064765c35ec6b23 feel free to reuse that one if you want.

Thanks!

@tizoc

Looks fine to me.

@michaelsauter michaelsauter referenced this issue from a commit in sitepoint/the86-client
@michaelsauter michaelsauter Use build_nested_query, of course
Not quite sure why I assumed build_query would work. I guess
because the tests passed and the tests failed when I used
build_nested query. The issue then however was a bug in rack
(see rack/rack#557), for which this
commit provides a quick fix.
33be937
@aaronpk

+1 Ended up having to do the same workaround as @michaelsauter above.

@OpakAlex

+1

@raggi raggi closed this in c34b579
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.