Couchbase

  • Log In Access more options
    • Online Help
    • GreenHopper Help
    • Agile Answers
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Agile Access more options (Alt+g)
  • Couchbase.com Access more options
    • Why NoSQL?
    • Couchbase Server
    • Download
    • Learn
    • Careers
Couchbase Ruby client library
  • Couchbase Ruby client library
  • RCBC-58

CAS block error

  • Agile Board
  • More Actions
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Won't Fix
  • Affects Version/s: 1.0.0
  • Fix Version/s: None
  • Component/s: library
  • Security Level: Public
  • Labels:
    None
  • Environment:
    Mac OSX, couchbase (1.1.2)

Description

Unexpected CAS error:

Expected output from:

cb.default_format = :document
cb.set("trans1", "{'karen': '400', 'dipti': '800', 'status':'init' }")=> 360287970189639680
cb.cas("trans1") do |val|
val["new"] = "new"
val
end

Would be {'karen': '400', 'dipti': '800', 'status':'init', 'new': 'new' }

but it returns:

IndexError: string not matched
from (irb):7:in `[]='

This is based on the rdoc example:

c.default_format = :document
c.set("foo", {"bar" => 1})
c.cas("foo") do |val|
  val["baz"] = 2
  val
end
c.get("foo") #=> {"bar" => 1, "baz" => 2}

Activity

Descending order - Click to sort in ascending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
  • Gerrit Reviews
Hide
Permalink
Karen Zeller added a comment - 18/Jul/12 1:52 PM
I will add this last point to the section on Using JSON docs in the Structuring Data chapter of dev. guide....
Show
Karen Zeller added a comment - 18/Jul/12 1:52 PM I will add this last point to the section on Using JSON docs in the Structuring Data chapter of dev. guide....
Hide
Permalink
Matt Ingenthron added a comment - 18/Jul/12 3:01 AM
Also note that quoting JSON with ' is actually not legal. It's supposed to be " . Some JSON parsers (particularly some Python libraries) are really lax about this, but what you have there isn't JSON. It's a semi-JSON like string.

See json.org
Show
Matt Ingenthron added a comment - 18/Jul/12 3:01 AM Also note that quoting JSON with ' is actually not legal. It's supposed to be " . Some JSON parsers (particularly some Python libraries) are really lax about this, but what you have there isn't JSON. It's a semi-JSON like string. See json.org
Hide
Permalink
Sergey Avseyev added a comment - 17/Jul/12 5:04 PM
It isn't bug here

Note what are you setting as document:

   "{'karen': '400', 'dipti': '800', 'status':'init' }"

This is a String, so it will be encoded as JSON string.

If you'd like to store a JSON Object, you should use Ruby Hash:

   {'karen' => '400', 'dipti' => '800', 'status' => 'init' }

I guess '400' and '800' shouldn't be specified as strings, therefore you might want to omit single quotes
Show
Sergey Avseyev added a comment - 17/Jul/12 5:04 PM It isn't bug here Note what are you setting as document:    "{'karen': '400', 'dipti': '800', 'status':'init' }" This is a String, so it will be encoded as JSON string. If you'd like to store a JSON Object, you should use Ruby Hash:    {'karen' => '400', 'dipti' => '800', 'status' => 'init' } I guess '400' and '800' shouldn't be specified as strings, therefore you might want to omit single quotes

People

  • Assignee:
    Sergey Avseyev
    Reporter:
    Karen Zeller
Vote (0)
Watch (0)

Dates

  • Created:
    17/Jul/12 4:33 PM
    Updated:
    13/Nov/12 4:24 AM
    Resolved:
    17/Jul/12 5:04 PM

Agile

  • View on Board
  • Atlassian JIRA (v5.2.4#845-sha1:c9f4cc4)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Couchbase. Try JIRA - bug tracking software for your team.