benoitc / couchbeam

Apache CouchDB client in Erlang
Other
242 stars 114 forks source link

couchbeam:save_docs not working without ids #28

Closed argl closed 14 years ago

argl commented 14 years ago

I tried bulk creating some documents via couchbeam:save_docs but could not get it to work. digging deeper it seems that the uuid generator returns uuids as strings and not binaries. that leads to the json enoder failing. i fixed the problem for me by patching the maybe_docid function in couchbeam_db

maybe_docid(#db{server=ServerState}, {DocProps}) ->
    #server_state{uuids_pid=UuidsPid} = ServerState,
    case proplists:get_value(<<"_id">>, DocProps) of
        undefined ->
            DocId = couchbeam_uuids:next_uuid(UuidsPid),
            {[{<<"_id">>, list_to_binary(DocId)}|DocProps]};
        _DocId ->
            {DocProps}
    end.
woelli commented 14 years ago

same problem here ... described fix also works for me

benoitc commented 14 years ago

fixed in last hed. Thanks!