-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for one sided relations (#3021)
## Relevant issue(s) Resolves #2830 ## Description Adds support for one sided relations.
- Loading branch information
1 parent
f5b67e4
commit 75adf50
Showing
3 changed files
with
115 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2024 Democratized Data Foundation | ||
// | ||
// 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 one_to_many | ||
|
||
import ( | ||
"testing" | ||
|
||
testUtils "github.com/sourcenetwork/defradb/tests/integration" | ||
) | ||
|
||
func TestQueryOneToMany_OneSided(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
Actions: []any{ | ||
testUtils.SchemaUpdate{ | ||
Schema: ` | ||
type Author { | ||
name: String | ||
} | ||
type Book { | ||
name: String | ||
author: Author | ||
} | ||
`, | ||
}, | ||
testUtils.CreateDoc{ | ||
Doc: `{ | ||
"name": "John Grisham" | ||
}`, | ||
}, | ||
testUtils.CreateDoc{ | ||
CollectionID: 1, | ||
DocMap: map[string]any{ | ||
"name": "Painted House", | ||
"author": testUtils.NewDocIndex(0, 0), | ||
}, | ||
}, | ||
testUtils.Request{ | ||
Request: `query { | ||
Book { | ||
name | ||
author { | ||
name | ||
} | ||
} | ||
}`, | ||
Results: map[string]any{ | ||
"Book": []map[string]any{ | ||
{ | ||
"name": "Painted House", | ||
"author": map[string]any{ | ||
"name": "John Grisham", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
testUtils.ExecuteTestCase(t, test) | ||
} |