Skip to content

Commit

Permalink
Merge branch 'develop' into nasdf/fix/json-default-value-panic
Browse files Browse the repository at this point in the history
  • Loading branch information
nasdf authored Oct 18, 2024
2 parents f65e8fc + 76f5c8a commit 2b8dceb
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 10 deletions.
4 changes: 1 addition & 3 deletions internal/connor/all.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package connor

import (
"github.com/sourcenetwork/defradb/client"

"github.com/sourcenetwork/immutable"
)

Expand Down Expand Up @@ -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
}
}

Expand Down
4 changes: 1 addition & 3 deletions internal/connor/any.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package connor

import (
"github.com/sourcenetwork/defradb/client"

"github.com/sourcenetwork/immutable"
)

Expand Down Expand Up @@ -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
}
}

Expand Down
26 changes: 26 additions & 0 deletions tests/integration/query/inline_array/with_filter_all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
26 changes: 26 additions & 0 deletions tests/integration/query/inline_array/with_filter_any_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
28 changes: 26 additions & 2 deletions tests/integration/query/json/with_all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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}}}) {
Expand Down
28 changes: 26 additions & 2 deletions tests/integration/query/json/with_any_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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}}}) {
Expand Down

0 comments on commit 2b8dceb

Please sign in to comment.