Closed frugardc closed 13 years ago
Thanks for the bug! Will take a look tonight.
This seems to be a SugarCRM bug:
account = SugarCRM::Account.first
SugarCRM.connection.set_entry('Accounts', :id => account.id, :name => 'A & B')
fails with invalid request. However, the JSON name-value hash that is passed in Connection#set_entry
is "name": "A & B"
, which is valid JSON (according to jsonlint.com)...
Yeah, this looks like a SugarCRM product bug. I'll see about opening a case tomorrow
I think this is an issue with the way I'm posting the JSON. If the total request length is < 3900 bytes, I send a "GET" request. When I send a GET, the JSON is encoded into the URL path, and since "&" symbols are used for joining URL parameters, it skips that symbol.
I'll look into pushing a fix today.
Now that you mention it, this explanation makes a lot of sense. SugarCRM wouldn't actually receive valid JSON, hence the error...
FYI, I've fixed this in my current checkout but I won't get around to merging the changes into head until I finish our next feature - Lazy Loaded Collections. Should be done later this week.
I fixed this and added tests for it. Please confirm and close!
Confirmed: can create account with name containing '&' and search for account with :conditions => {:name => "LIKE '%&%'"}
Just updated to version 0.9.9. Works now. Thanks!
Removing the & allows the save to happen.
irb(main):086:0> a = SugarCRM::Account.new
irb(main):087:0> a.name = "COHEN, WEISS & SIMON LLP"
=> "COHEN, WEISS & SIMON LLP"
irb(main):088:0> a.save
=> false
irb(main):089:0> a.errors
=> #<Set: {}>
irb(main):090:0> a.name = "COHEN, WEISS SIMON LLP"
=> "COHEN, WEISS SIMON LLP"
irb(main):091:0> a.save
=> true
irb(main):092:0>