Error with "Implicit Operators" #2976
-
DescriptionI'm putting on practice the CouchDB documentation and I read about "Implicit Operators", but COUCHD ignore my firts condiction when i send two condictions and it should use the implicit Current BehaviorI use the next query:
But COUCHDB is ignoring my firts condition:
And changing the condictions:
CouchDB also ignored my firts condiction:
Expected BehaviourCOUCHD should response with:
But I only can get this with Explicit Operators:
Your Environment
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
Hi @hamiltonsalazar , That's because what you're specifying isn't really valid JSON. In any JSON object in CouchDB, each key must be unique. Consider the following CouchDB document: {
"_id": "myname",
"name": "Joan",
"name": "Fred"
} We can't store each name, so we pick the last one and use that. "Last key wins." In your query: "selector" : {
"age": {
"$lte": 30
},
"age": {
"$gte": 25
}
},
... you have two keys under Implicit operators work fine when each provided key is different, so that the actual JSON that you're entering is valid JSON. |
Beta Was this translation helpful? Give feedback.
-
I would say its a documentation bug. If you run explain on your query what does it return back? If it doesn't automatically add in the |
Beta Was this translation helpful? Give feedback.
-
It appears that the (node1@127.0.0.1)377> jiffy:decode(<<"{\"foo\":\"bar\", \"foo\":\"baz\"}">>, [return_maps]).
#{<<"foo">> => <<"baz">>}
(node1@127.0.0.1)378> jiffy:decode(<<"{\"foo\":\"bar\", \"foo\":\"baz\"}">>, [dedup_keys, return_maps]).
** exception error: bad argument
in function jiffy:nif_decode_init/2
called as jiffy:nif_decode_init(<<"{\"foo\":\"bar\", \"foo\":\"baz\"}">>,
[dedup_keys,return_maps])
in call from jiffy:decode/2 (src/jiffy.erl, line 69) And on master at least, it seems that the So the reported behavior seems a bit puzzling on the surface. I'll try to repro once I have more time. |
Beta Was this translation helpful? Give feedback.
-
The query should rather be:
I think there is also a documentation bug we can't have two keys in the selector with the same name |
Beta Was this translation helpful? Give feedback.
The query should rather be:
I think there is also a documentation bug we can't have two keys in the selector with the same name