couchbase/couchbase-lite-ios

`ArrayFunction.contains` does not evaluate to correct result for boolean values

blaugold opened this issue · 2 comments

Describe the bug
ArrayFunction.contains does not evaluate to true when checking whether an array contains a boolean value, and the array does contain this value.

To Reproduce

  1. Clone https://github.com/blaugold/CouchbaseLiteIssues
  2. Open in Xcode
  3. Run tests in ArrayContainsTests.swift

Test Logs

Test Suite 'Selected tests' started at 2021-08-01 11:26:56.075
Test Suite 'Tests.xctest' started at 2021-08-01 11:26:56.076
Test Suite 'ArrayContainsTests' started at 2021-08-01 11:26:56.076
2021-08-01 11:26:56.078117+0200 xctest[65988:741040] CouchbaseLite/2.8.4 (Swift; macOS 11.5.1) Build/18 Commit/5ea5cd71+CHANGES LiteCore/2.8.4 (18)
2021-08-01 11:26:56.080045+0200 xctest[65988:741040] CouchbaseLite Database WARNING: Database.log.file.config is nil, meaning file logging is disabled. Log files required for product support are not being generated.
Test Case '-[Tests.ArrayContainsTests testContainsBoolean]' started.
SELECT fl_result(array_contains(array_of(fl_bool(0)), fl_bool(1))) FROM kv_default AS _doc WHERE (_doc.flags & 1 = 0)

2|0|0| SCAN TABLE kv_default AS _doc

{"WHAT":[["ARRAY_CONTAINS()",["[]",false],true]]}

SELECT fl_result(array_contains(array_of(fl_bool(1)), fl_bool(1))) FROM kv_default AS _doc WHERE (_doc.flags & 1 = 0)

2|0|0| SCAN TABLE kv_default AS _doc

{"WHAT":[["ARRAY_CONTAINS()",["[]",true],true]]}

/Users/gabriel/Dev/CouchbaseLiteIssues/Tests/ArrayContainsTests.swift:38: error: -[Tests.ArrayContainsTests testContainsBoolean] : XCTAssertTrue failed
Test Case '-[Tests.ArrayContainsTests testContainsBoolean]' failed (4.936 seconds).
Test Case '-[Tests.ArrayContainsTests testContainsString]' started.
SELECT fl_result(array_contains(array_of('a'), 'a')) FROM kv_default AS _doc WHERE (_doc.flags & 1 = 0)

2|0|0| SCAN TABLE kv_default AS _doc

{"WHAT":[["ARRAY_CONTAINS()",["[]","a"],"a"]]}

SELECT fl_result(array_contains(array_of('a'), 'b')) FROM kv_default AS _doc WHERE (_doc.flags & 1 = 0)

2|0|0| SCAN TABLE kv_default AS _doc

{"WHAT":[["ARRAY_CONTAINS()",["[]","a"],"b"]]}

Test Case '-[Tests.ArrayContainsTests testContainsString]' passed (0.001 seconds).
Test Suite 'ArrayContainsTests' failed at 2021-08-01 11:27:01.024.
	 Executed 2 tests, with 1 failure (0 unexpected) in 4.937 (4.948) seconds
Test Suite 'Tests.xctest' failed at 2021-08-01 11:27:01.025.
	 Executed 2 tests, with 1 failure (0 unexpected) in 4.937 (4.949) seconds
Test Suite 'Selected tests' failed at 2021-08-01 11:27:01.025.
	 Executed 2 tests, with 1 failure (0 unexpected) in 4.937 (4.950) seconds
Program ended with exit code: 1

Platform (please complete the following information):

  • Device: MacBook Pro
  • OS: macOS
  • Couchbase Version: CouchbaseLiteSwift 2.8.4

Closing this, fix will be available in upcoming release.