I'm back on the issue. In a recent talk we agreed that we should go by Rails
conventions as much as applicable, so I went and ported some Rails tests to
JavaScript. I also made minor changes to toQuery methods, and here is where
my patch stands now:

   1. { foo:'', bar:null } becomes "foo=&bar=". Sam, is this OK?
   "foo=&bar" really isn't a proper query :-/
   2. { bar:undefined } is skipped
   3. for now, "a=b&bar" becomes { a:'b', bar:undefined }. That should be
   null instead, right?
   4. "foo=a=b=c" becomes { foo:'a=b=c' }
   5. it handles "&a=b&&&&c=d" properly, too

Now, for the hard part - collections. Rails and PHP do some magic regarding
the square brackets, but I don't think we are to follow that because we are
at the client, not the backend. Magic around square brackets would break
form serializing.

   1. { foo:['a', 'b', 'c'] } becomes "foo=a&foo=b&foo=c". In Rails,
   square brackets are added to the keys
   2. "foo=a&foo=b&foo=c" becomes { foo:['a', 'b', 'c'] }. Rails (PHP
   too, I think) would preserve only the first value. Ruby preserves all.
   3. "foo[]=a&foo[]=b&foo[]=c" becomes { 'foo[]':['a', 'b', 'c'] }.
   Rails and PHP would now preserve all values, but remove the square brackets
   from the key.
   4. { foo:[null] } becomes "foo="
   5. { foo:[undefined] } or { foo:[] } becomes ""
   6. "color=&color=blue" now becomes { color:['', 'blue'] }, not {
   color:'blue' } as before.


On 3/2/07, Mislav Marohnić <[EMAIL PROTECTED] > wrote:
> I'm combining Tobie's and mine Hash patches to see how they work out.
> These changes fix 3 bugs and remove some premature optimization from
> toQueryString method. Now, ticket #7494 by Skirch is about nested hashsupport 
> - I like it and am thinking about rolling it in for the next
> release. There are a number of questions regarding all these changes,
> though. I'd like to sort out the inconsistencies.

You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 

Reply via email to