Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow querying of 9th, 19th, 29th, etc collections #2819

Merged
315 changes: 315 additions & 0 deletions tests/integration/issues/2810_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,315 @@
// Copyright 2024 Democratized Data Foundation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Praise: Thanks a bunch for documenting these! Really nice to see the issue narrowed down with the edge cases you highlighted.

//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package issues

import (
"testing"

testUtils "github.com/sourcenetwork/defradb/tests/integration"
)

func TestSimple_WithSevenDummyTypesBefore(t *testing.T) {
test := testUtils.TestCase{
Actions: []any{
testUtils.SchemaUpdate{
Schema: `
type Type0 {
f: String
}
type Type1 {
f: String
}
type Type2 {
f: String
}
type Type3 {
f: String
}
type Type4 {
f: String
}
type Type5 {
f: String
}
type Type6 {
f: String
}

type User {
name: String
}
`,
},
testUtils.CreateDoc{
CollectionID: 7,
DocMap: map[string]any{
"name": "John",
},
},
testUtils.Request{
Request: `
query {
User {
name
}
}
`,
Results: []map[string]any{
{
"name": "John",
},
},
},
},
}

testUtils.ExecuteTestCase(t, test)
}

func TestSimple_WithEightDummyTypesBefore(t *testing.T) {
test := testUtils.TestCase{
Actions: []any{
testUtils.SchemaUpdate{
Schema: `
type Type0 {
f: String
}
type Type1 {
f: String
}
type Type2 {
f: String
}
type Type3 {
f: String
}
type Type4 {
f: String
}
type Type5 {
f: String
}
type Type6 {
f: String
}
type Type7 {
f: String
}

type User {
name: String
}
`,
},
testUtils.CreateDoc{
CollectionID: 8,
DocMap: map[string]any{
"name": "John",
},
},
testUtils.Request{
Request: `
query {
User {
name
}
}
`,
Results: []map[string]any{},
},
},
}

testUtils.ExecuteTestCase(t, test)
}

func TestSimple_WithEightDummyTypesBeforeInSplitDeclaration(t *testing.T) {
test := testUtils.TestCase{
Actions: []any{
testUtils.SchemaUpdate{
Schema: `
type Type0 {
f: String
}
type Type1 {
f: String
}
type Type2 {
f: String
}
type Type3 {
f: String
}
type Type4 {
f: String
}
type Type5 {
f: String
}
type Type6 {
f: String
}
type Type7 {
f: String
}
`,
},
testUtils.SchemaUpdate{
Schema: `
type User {
name: String
}
`,
},
testUtils.CreateDoc{
CollectionID: 8,
DocMap: map[string]any{
"name": "John",
},
},
testUtils.Request{
Request: `
query {
User {
name
}
}
`,
Results: []map[string]any{},
},
},
}

testUtils.ExecuteTestCase(t, test)
}

func TestSimple_WithEightDummyTypesAfter(t *testing.T) {
test := testUtils.TestCase{
Actions: []any{
testUtils.SchemaUpdate{
Schema: `
type User {
name: String
}

type Type0 {
f: String
}
type Type1 {
f: String
}
type Type2 {
f: String
}
type Type3 {
f: String
}
type Type4 {
f: String
}
type Type5 {
f: String
}
type Type6 {
f: String
}
type Type7 {
f: String
}
`,
},
testUtils.CreateDoc{
CollectionID: 0,
DocMap: map[string]any{
"name": "John",
},
},
testUtils.Request{
Request: `
query {
User {
name
}
}
`,
Results: []map[string]any{
{
"name": "John",
},
},
},
},
}

testUtils.ExecuteTestCase(t, test)
}

func TestSimple_WithSevenDummyTypesBeforeAndOneAfter(t *testing.T) {
test := testUtils.TestCase{
Actions: []any{
testUtils.SchemaUpdate{
Schema: `
type Type0 {
f: String
}
type Type1 {
f: String
}
type Type2 {
f: String
}
type Type3 {
f: String
}
type Type4 {
f: String
}
type Type5 {
f: String
}
type Type6 {
f: String
}

type User {
name: String
}

type Type7 {
f: String
}
`,
},
testUtils.CreateDoc{
CollectionID: 7,
DocMap: map[string]any{
"name": "John",
},
},
testUtils.Request{
Request: `
query {
User {
name
}
}
`,
Results: []map[string]any{
{
"name": "John",
},
},
},
},
}

testUtils.ExecuteTestCase(t, test)
}
1 change: 1 addition & 0 deletions tests/integration/utils2.go
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,7 @@ func createDocViaGQL(
node client.DB,
collections []client.Collection,
) ([]*client.Document, error) {
println(fmt.Sprint(collections))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: is it left here intentional?

Copy link
Contributor Author

@AndrewSisley AndrewSisley Jul 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not :) And I should have been more careful so soon after the mutation type bug :) Thanks for spotting

  • remove print

collection := collections[action.CollectionID]
var input string

Expand Down