From afcfed69aeb6a0806ccdeb0a146331d916c818cf Mon Sep 17 00:00:00 2001 From: hulkoba Date: Wed, 12 Nov 2025 10:29:40 +0100 Subject: [PATCH 1/2] test: port 10 disable array length field to elixir --- test/elixir/test/config/search.elixir | 4 ++ .../10_disable_array_length_field_test.exs | 50 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 test/elixir/test/mango/10_disable_array_length_field_test.exs diff --git a/test/elixir/test/config/search.elixir b/test/elixir/test/config/search.elixir index 87715d4caf3..43bdcf533ac 100644 --- a/test/elixir/test/config/search.elixir +++ b/test/elixir/test/config/search.elixir @@ -38,5 +38,9 @@ ], "LimitTests": [ "limit field" + ], + "DisableIndexArrayLengthsTest": [ + "disable index array length", + "enable index array length" ] } diff --git a/test/elixir/test/mango/10_disable_array_length_field_test.exs b/test/elixir/test/mango/10_disable_array_length_field_test.exs new file mode 100644 index 00000000000..fa032aeab85 --- /dev/null +++ b/test/elixir/test/mango/10_disable_array_length_field_test.exs @@ -0,0 +1,50 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +defmodule DisableIndexArrayLengthsTest do + use CouchTestCase + + @db_name "disable-array-length-field-docs" + + setup do + UserDocs.setup(@db_name, "text") + + MangoDatabase.create_text_index(@db_name, + ddoc: "disable_index_array_lengths", + analyzer: "keyword", + index_array_lengths: false + ) + + MangoDatabase.create_text_index(@db_name, + ddoc: "explicit_enable_index_array_lengths", + analyzer: "keyword", + index_array_lengths: true + ) + :ok + end + + test "disable index array length" do + q = %{"favorites" => %{"$size" => 4}} + {:ok, docs} = MangoDatabase.find(@db_name, q, use_index: "disable_index_array_lengths") + assert docs == [] + end + + test "enable index array length" do + q = %{"favorites" => %{"$size" => 4}} + {:ok, docs} = MangoDatabase.find(@db_name, q, use_index: "explicit_enable_index_array_lengths") + + assert length(docs) == 4 + for doc <- docs do + assert length(doc["favorites"]) == 4 + end + end +end From 0818957a567ce65d67ea23fccc9259e017883a06 Mon Sep 17 00:00:00 2001 From: hulkoba Date: Wed, 12 Nov 2025 10:30:14 +0100 Subject: [PATCH 2/2] test: deprecate 10 disable array length field python test --- .../10-disable-array-length-field-test.py | 43 ------------------- 1 file changed, 43 deletions(-) delete mode 100644 src/mango/test/10-disable-array-length-field-test.py diff --git a/src/mango/test/10-disable-array-length-field-test.py b/src/mango/test/10-disable-array-length-field-test.py deleted file mode 100644 index 297ebeacec4..00000000000 --- a/src/mango/test/10-disable-array-length-field-test.py +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - -import mango -import unittest - - -@unittest.skipUnless(mango.has_text_service(), "requires text service") -class DisableIndexArrayLengthsTest(mango.UserDocsTextTests): - def setUp(self): - self.db.create_text_index( - ddoc="disable_index_array_lengths", - analyzer="keyword", - index_array_lengths=False, - ) - self.db.create_text_index( - ddoc="explicit_enable_index_array_lengths", - analyzer="keyword", - index_array_lengths=True, - ) - - def test_disable_index_array_length(self): - docs = self.db.find( - {"favorites": {"$size": 4}}, use_index="disable_index_array_lengths" - ) - assert len(docs) == 0 - - def test_enable_index_array_length(self): - docs = self.db.find( - {"favorites": {"$size": 4}}, use_index="explicit_enable_index_array_lengths" - ) - assert len(docs) > 0 - for d in docs: - assert len(d["favorites"]) == 4