diff --git a/internal/connor/all.go b/internal/connor/all.go index ce2557d25b..bf607b583b 100644 --- a/internal/connor/all.go +++ b/internal/connor/all.go @@ -1,8 +1,6 @@ package connor import ( - "github.com/sourcenetwork/defradb/client" - "github.com/sourcenetwork/immutable" ) @@ -39,7 +37,7 @@ func all(condition, data any) (bool, error) { return allSlice(condition, t) default: - return false, client.NewErrUnhandledType("data", data) + return false, nil } } diff --git a/internal/connor/any.go b/internal/connor/any.go index 7eea2a7bce..ecd16ce992 100644 --- a/internal/connor/any.go +++ b/internal/connor/any.go @@ -1,8 +1,6 @@ package connor import ( - "github.com/sourcenetwork/defradb/client" - "github.com/sourcenetwork/immutable" ) @@ -39,7 +37,7 @@ func anyOp(condition, data any) (bool, error) { return anySlice(condition, t) default: - return false, client.NewErrUnhandledType("data", data) + return false, nil } } diff --git a/tests/integration/query/inline_array/with_filter_all_test.go b/tests/integration/query/inline_array/with_filter_all_test.go index 1661c54731..a558a70a23 100644 --- a/tests/integration/query/inline_array/with_filter_all_test.go +++ b/tests/integration/query/inline_array/with_filter_all_test.go @@ -303,3 +303,29 @@ func TestQueryInlineNotNullBooleanArray_WithAllFilter_Succeeds(t *testing.T) { executeTestCase(t, test) } + +func TestQueryInlineStringArray_WithAllFilterAndNullValue_Succeeds(t *testing.T) { + test := testUtils.TestCase{ + Description: "Simple inline array, filtered all of string array with null", + Actions: []any{ + testUtils.CreateDoc{ + Doc: `{ + "name": "Islam", + "pageHeaders": null + }`, + }, + testUtils.Request{ + Request: `query { + Users(filter: {pageHeaders: {_all: {_eq: null}}}) { + name + } + }`, + Results: map[string]any{ + "Users": []map[string]any{}, + }, + }, + }, + } + + executeTestCase(t, test) +} diff --git a/tests/integration/query/inline_array/with_filter_any_test.go b/tests/integration/query/inline_array/with_filter_any_test.go index 0dfc815595..15d3f701e4 100644 --- a/tests/integration/query/inline_array/with_filter_any_test.go +++ b/tests/integration/query/inline_array/with_filter_any_test.go @@ -303,3 +303,29 @@ func TestQueryInlineNotNullBooleanArray_WithAnyFilter_Succeeds(t *testing.T) { executeTestCase(t, test) } + +func TestQueryInlineStringArray_WithAnyFilterAndNullValue_Succeeds(t *testing.T) { + test := testUtils.TestCase{ + Description: "Simple inline array, filtered any of string array with null", + Actions: []any{ + testUtils.CreateDoc{ + Doc: `{ + "name": "Islam", + "pageHeaders": null + }`, + }, + testUtils.Request{ + Request: `query { + Users(filter: {pageHeaders: {_any: {_eq: null}}}) { + name + } + }`, + Results: map[string]any{ + "Users": []map[string]any{}, + }, + }, + }, + } + + executeTestCase(t, test) +} diff --git a/tests/integration/query/json/with_all_test.go b/tests/integration/query/json/with_all_test.go index 918c51e5bb..b0d12765ae 100644 --- a/tests/integration/query/json/with_all_test.go +++ b/tests/integration/query/json/with_all_test.go @@ -16,9 +16,9 @@ import ( testUtils "github.com/sourcenetwork/defradb/tests/integration" ) -func TestQueryJSON_WithAllFilter_ShouldFilter(t *testing.T) { +func TestQueryJSON_WithAllFilterWithAllTypes_ShouldFilter(t *testing.T) { test := testUtils.TestCase{ - Description: "Simple JSON array, filtered all of string array", + Description: "Simple JSON array, filtered all of all types array", Actions: []any{ testUtils.SchemaUpdate{ Schema: `type Users { @@ -38,6 +38,30 @@ func TestQueryJSON_WithAllFilter_ShouldFilter(t *testing.T) { "custom": [null, false, "second", {"one": 1}, [1, 2]] }`, }, + testUtils.CreateDoc{ + Doc: `{ + "name": "Islam", + "custom": null + }`, + }, + testUtils.CreateDoc{ + Doc: `{ + "name": "Keenan", + "custom": 0 + }`, + }, + testUtils.CreateDoc{ + Doc: `{ + "name": "Andy", + "custom": "" + }`, + }, + testUtils.CreateDoc{ + Doc: `{ + "name": "John", + "custom": true + }`, + }, testUtils.Request{ Request: `query { Users(filter: {custom: {_all: {_ne: null}}}) { diff --git a/tests/integration/query/json/with_any_test.go b/tests/integration/query/json/with_any_test.go index d38d3e83e8..e79e90946b 100644 --- a/tests/integration/query/json/with_any_test.go +++ b/tests/integration/query/json/with_any_test.go @@ -16,9 +16,9 @@ import ( testUtils "github.com/sourcenetwork/defradb/tests/integration" ) -func TestQueryJSON_WithAnyFilter_ShouldFilter(t *testing.T) { +func TestQueryJSON_WithAnyFilterWithAllTypes_ShouldFilter(t *testing.T) { test := testUtils.TestCase{ - Description: "Simple JSON array, filtered any of string array", + Description: "Simple JSON array, filtered any of all types array", Actions: []any{ testUtils.SchemaUpdate{ Schema: `type Users { @@ -38,6 +38,30 @@ func TestQueryJSON_WithAnyFilter_ShouldFilter(t *testing.T) { "custom": [null, false, "second", {"one": 1}, [1, 2]] }`, }, + testUtils.CreateDoc{ + Doc: `{ + "name": "Islam", + "custom": null + }`, + }, + testUtils.CreateDoc{ + Doc: `{ + "name": "Keenan", + "custom": 0 + }`, + }, + testUtils.CreateDoc{ + Doc: `{ + "name": "Andy", + "custom": "" + }`, + }, + testUtils.CreateDoc{ + Doc: `{ + "name": "John", + "custom": true + }`, + }, testUtils.Request{ Request: `query { Users(filter: {custom: {_any: {_eq: null}}}) {