Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/2.3.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
bobthecow committed Jul 29, 2013
2 parents 2bdd2c7 + 81d1119 commit 4c164cb
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 15 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.markdown
@@ -1,3 +1,10 @@
## v2.3.7

* [Fix #126][i126] — Resolve bug editing non-ObjectId `_id` in Ruby 1.8.7.

[i126]: https://github.com/bobthecow/genghis/issues/126


## v2.3.6

* Change grippie cursor to `row-resize` — Thanks @Zatsugami.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
2.3.6
2.3.7
14 changes: 7 additions & 7 deletions genghis.php

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions genghis.rb

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions spec/requests/api_spec.rb
Expand Up @@ -643,6 +643,22 @@
test: 2
end

it 'can deal with non-objectid _id properties' do
id = "testier"
@coll.insert({_id: id})
id_str = "~#{Base64.encode64('"testier"')}"
res = @api.put do |req|
req.url '/servers/localhost/databases/__genghis_spec_test__/collections/spec_docs/documents/' + id_str
req.headers['Content-Type'] = 'application/json'
req.body = { test: 1 }.to_json
end

res.status.should eq 200
res.body.should match_json_expression \
_id: "testier",
test: 1
end

it 'returns 400 if a document id is updated' do
id = @coll.insert({test: 1})
res = @api.put do |req|
Expand Down
2 changes: 1 addition & 1 deletion src/rb/genghis/models/collection.rb
Expand Up @@ -124,7 +124,7 @@ def to_json(*)
def thunk_mongo_id(doc_id)
if doc_id.is_a? BSON::ObjectId
doc_id
elsif (doc_id[0] == '~')
elsif (doc_id[0..0] == '~')
doc_id = Base64.decode64(doc_id[1..-1])
::Genghis::JSON.decode("{\"_id\":#{doc_id}}")['_id']
else
Expand Down

0 comments on commit 4c164cb

Please sign in to comment.