You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by jc...@apache.org on 2026/07/28 13:17:16 UTC
(couchdb) 14/16: fix: Format Mango VDU errors correctly when a doc contains an empty-string field name
This is an automated email from the ASF dual-hosted git repository.
jcoglan pushed a commit to branch mango-match-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit e91210a721a0bf60d00a84c0882c3002530557d9
Author: James Coglan <ja...@neighbourhood.ie>
AuthorDate: Mon Jul 20 12:32:47 2026 +0100
fix: Format Mango VDU errors correctly when a doc contains an empty-string field name
---
src/mango/src/mango_selector.erl | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/mango/src/mango_selector.erl b/src/mango/src/mango_selector.erl
index dac0b2e14..375223a84 100644
--- a/src/mango/src/mango_selector.erl
+++ b/src/mango/src/mango_selector.erl
@@ -815,6 +815,8 @@ format_op(size, true, mismatch, [N]) ->
format_path([]) ->
[];
+format_path([<<>> | Rest]) ->
+ format_path(Rest) ++ [<<"">>];
format_path([Item | Rest]) when is_binary(Item) ->
{ok, Path} = mango_util:parse_field(Item),
format_path(Rest) ++ Path;
@@ -2148,6 +2150,7 @@ match_elemmatch_test() ->
match_keymapmatch_test() ->
check_selector({[{<<"$keyMapMatch">>, {[{<<"$regex">>, <<"^[a-z]+$">>}]}}]}, [
{true, {[{<<"hello">>, 0}]}},
+ {false, {[{<<"">>, 42}]}},
{true, {[{<<"a">>, 1}, {<<"b">>, 2}]}},
{true, {[{<<"a">>, 1}, {<<"b4">>, 2}]}},
{false, {[{<<"b4">>, 2}]}},
@@ -2734,6 +2737,7 @@ format_path_test() ->
?assertEqual([], format_path([])),
?assertEqual([<<"a">>], format_path([<<"a">>])),
?assertEqual([<<"a">>, <<"b">>], format_path([<<"b">>, <<"a">>])),
+ ?assertEqual([<<"a">>, <<"">>], format_path([<<"">>, <<"a">>])),
?assertEqual([<<"a">>, <<"b">>, <<"c">>], format_path([<<"b.c">>, <<"a">>])),
?assertEqual([<<"a">>, 42, <<"b">>, <<"c">>], format_path([<<"b.c">>, 42, <<"a">>])).