Skip to content

Commit

Permalink
PR(MAIN): Rename dockey/dockeys to docID(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzadlone committed Oct 19, 2023
1 parent 2b1fc35 commit 3ad518e
Show file tree
Hide file tree
Showing 53 changed files with 245 additions and 240 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ To get the most recent commit in the MerkleDAG for the document identified as `b
```shell
defradb client query '
query {
latestCommits(dockey: "bae-91171025-ed21-50e3-b0dc-e31bccdfa1ab") {
latestCommits(docID: "bae-91171025-ed21-50e3-b0dc-e31bccdfa1ab") {
cid
delta
height
Expand Down
11 changes: 4 additions & 7 deletions client/request/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,20 @@ const (

Cid = "cid"
Data = "data"
DocKey = "dockey"
DocKeys = "dockeys"
FieldName = "field"
FieldIDName = "fieldId"
ShowDeleted = "showDeleted"

DocID = "docID"
DocIDs = "docIDs"

FilterClause = "filter"
GroupByClause = "groupBy"
LimitClause = "limit"
OffsetClause = "offset"
OrderClause = "order"
DepthClause = "depth"

DocID = "docID"
DocIDs = "docIDs"

AverageFieldName = "_avg"
CountFieldName = "_count"
KeyFieldName = "_docID"
Expand All @@ -58,7 +56,6 @@ const (
LinksFieldName = "links"
HeightFieldName = "height"
CidFieldName = "cid"
DockeyFieldName = "dockey"
CollectionIDFieldName = "collectionID"
SchemaVersionIDFieldName = "schemaVersionId"
FieldNameFieldName = "fieldName"
Expand Down Expand Up @@ -103,7 +100,7 @@ var (
VersionFields = []string{
HeightFieldName,
CidFieldName,
DockeyFieldName,
DocID,
CollectionIDFieldName,
SchemaVersionIDFieldName,
FieldNameFieldName,
Expand Down
9 changes: 8 additions & 1 deletion merkle/clock/clock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
cid "github.com/ipfs/go-cid"
ds "github.com/ipfs/go-datastore"

"github.com/sourcenetwork/defradb/client/request"
"github.com/sourcenetwork/defradb/core"
ccid "github.com/sourcenetwork/defradb/core/cid"
"github.com/sourcenetwork/defradb/core/crdt"
Expand All @@ -32,7 +33,13 @@ func newTestMerkleClock() *MerkleClock {

multistore := datastore.MultiStoreFrom(s)
reg := crdt.NewLWWRegister(multistore.Rootstore(), core.CollectionSchemaVersionKey{}, core.DataStoreKey{}, "")
return NewMerkleClock(multistore.Headstore(), multistore.DAGstore(), core.HeadStoreKey{DocKey: "dockey", FieldId: "1"}, reg).(*MerkleClock)
return NewMerkleClock(
multistore.Headstore(),
multistore.DAGstore(),
core.HeadStoreKey{DocKey: request.DocID, FieldId: "1"},
reg,
).(*MerkleClock)

}

func TestNewMerkleClock(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion planner/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func (n *dagScanNode) dagBlockToNodeDoc(block blocks.Block) (core.Doc, []*ipld.L
}

n.commitSelect.DocumentMapping.SetFirstOfName(&commit,
request.DockeyFieldName, string(dockey))
request.DocID, string(dockey))

collection, err := n.planner.db.GetCollectionByVersionID(n.planner.ctx, schemaVersionId)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion request/graphql/parser/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func parseCommitSelect(schema gql.Schema, parent *gql.Object, field *ast.Field)

for _, argument := range field.Arguments {
prop := argument.Name.Value
if prop == request.DocKey {
if prop == request.DocID {
raw := argument.Value.(*ast.StringValue)
commit.DocKey = immutable.Some(raw.Value)
} else if prop == request.Cid {
Expand Down
4 changes: 2 additions & 2 deletions request/graphql/parser/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ func parseSelect(
}

slct.Filter = filter
case request.DocKey: // parse single dockey query field
case request.DocID: // parse single document id field
val := astValue.(*ast.StringValue)
slct.DocKeys = immutable.Some([]string{val.Value})
case request.DocKeys:
case request.DocIDs:
docKeyValues := astValue.(*ast.ListValue).Values
docKeys := make([]string, len(docKeyValues))
for i, value := range docKeyValues {
Expand Down
26 changes: 13 additions & 13 deletions request/graphql/schema/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ func (g *Generator) createExpandedFieldList(
Description: f.Description,
Type: gql.NewList(t),
Args: gql.FieldConfigArgument{
"dockey": schemaTypes.NewArgConfig(gql.String, dockeyArgDescription),
"dockeys": schemaTypes.NewArgConfig(gql.NewList(gql.NewNonNull(gql.String)), dockeysArgDescription),
request.DocID: schemaTypes.NewArgConfig(gql.String, dockeyArgDescription),
request.DocIDs: schemaTypes.NewArgConfig(gql.NewList(gql.NewNonNull(gql.String)), dockeysArgDescription),
"filter": schemaTypes.NewArgConfig(
g.manager.schema.TypeMap()[typeName+"FilterArg"],
listFieldFilterArgDescription,
Expand Down Expand Up @@ -942,10 +942,10 @@ func (g *Generator) genTypeMutationUpdateField(
Description: updateDocumentsDescription,
Type: gql.NewList(obj),
Args: gql.FieldConfigArgument{
schemaTypes.DocID: schemaTypes.NewArgConfig(gql.ID, updateIDArgDescription),
schemaTypes.DocIDs: schemaTypes.NewArgConfig(gql.NewList(gql.ID), updateIDsArgDescription),
"filter": schemaTypes.NewArgConfig(filter, updateFilterArgDescription),
"data": schemaTypes.NewArgConfig(gql.String, updateDataArgDescription),
request.DocID: schemaTypes.NewArgConfig(gql.ID, updateIDArgDescription),
request.DocIDs: schemaTypes.NewArgConfig(gql.NewList(gql.ID), updateIDsArgDescription),
"filter": schemaTypes.NewArgConfig(filter, updateFilterArgDescription),
"data": schemaTypes.NewArgConfig(gql.String, updateDataArgDescription),
},
}
return field, nil
Expand All @@ -960,9 +960,9 @@ func (g *Generator) genTypeMutationDeleteField(
Description: deleteDocumentsDescription,
Type: gql.NewList(obj),
Args: gql.FieldConfigArgument{
schemaTypes.DocID: schemaTypes.NewArgConfig(gql.ID, deleteIDArgDescription),
schemaTypes.DocIDs: schemaTypes.NewArgConfig(gql.NewList(gql.ID), deleteIDsArgDescription),
"filter": schemaTypes.NewArgConfig(filter, deleteFilterArgDescription),
request.DocID: schemaTypes.NewArgConfig(gql.ID, deleteIDArgDescription),
request.DocIDs: schemaTypes.NewArgConfig(gql.NewList(gql.ID), deleteIDsArgDescription),
"filter": schemaTypes.NewArgConfig(filter, deleteFilterArgDescription),
},
}
return field, nil
Expand Down Expand Up @@ -1159,10 +1159,10 @@ func (g *Generator) genTypeQueryableFieldList(
Description: obj.Description(),
Type: gql.NewList(obj),
Args: gql.FieldConfigArgument{
"dockey": schemaTypes.NewArgConfig(gql.String, dockeyArgDescription),
"dockeys": schemaTypes.NewArgConfig(gql.NewList(gql.NewNonNull(gql.String)), dockeysArgDescription),
"cid": schemaTypes.NewArgConfig(gql.String, cidArgDescription),
"filter": schemaTypes.NewArgConfig(config.filter, selectFilterArgDescription),
request.DocID: schemaTypes.NewArgConfig(gql.String, dockeyArgDescription),
request.DocIDs: schemaTypes.NewArgConfig(gql.NewList(gql.NewNonNull(gql.String)), dockeysArgDescription),
"cid": schemaTypes.NewArgConfig(gql.String, cidArgDescription),
"filter": schemaTypes.NewArgConfig(config.filter, selectFilterArgDescription),
"groupBy": schemaTypes.NewArgConfig(
gql.NewList(gql.NewNonNull(config.groupBy)),
schemaTypes.GroupByArgDescription,
Expand Down
12 changes: 6 additions & 6 deletions request/graphql/schema/types/commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var (
Description: commitCIDFieldDescription,
Type: gql.String,
},
"dockey": &gql.Field{
request.DocID: &gql.Field{
Description: commitDockeyFieldDescription,
Type: gql.String,
},
Expand Down Expand Up @@ -125,7 +125,7 @@ var (
Description: commitCIDFieldDescription,
Type: OrderingEnum,
},
"dockey": &gql.InputObjectFieldConfig{
request.DocID: &gql.InputObjectFieldConfig{
Description: commitDockeyFieldDescription,
Type: OrderingEnum,
},
Expand All @@ -150,8 +150,8 @@ var (
Value: "cid",
Description: commitCIDFieldDescription,
},
"dockey": &gql.EnumValueConfig{
Value: "dockey",
request.DocID: &gql.EnumValueConfig{
Value: request.DocID,
Description: commitDockeyFieldDescription,
},
"collectionID": &gql.EnumValueConfig{
Expand All @@ -175,7 +175,7 @@ var (
Description: commitsQueryDescription,
Type: gql.NewList(CommitObject),
Args: gql.FieldConfigArgument{
"dockey": NewArgConfig(gql.ID, commitDockeyArgDescription),
request.DocID: NewArgConfig(gql.ID, commitDockeyArgDescription),
request.FieldIDName: NewArgConfig(gql.String, commitFieldIDArgDescription),
"order": NewArgConfig(CommitsOrderArg, OrderArgDescription),
"cid": NewArgConfig(gql.ID, commitCIDArgDescription),
Expand All @@ -198,7 +198,7 @@ var (
Description: latestCommitsQueryDescription,
Type: gql.NewList(CommitObject),
Args: gql.FieldConfigArgument{
"dockey": NewArgConfig(gql.NewNonNull(gql.ID), commitDockeyArgDescription),
request.DocID: NewArgConfig(gql.NewNonNull(gql.ID), commitDockeyArgDescription),
request.FieldIDName: NewArgConfig(gql.String, commitFieldIDArgDescription),
},
}
Expand Down
3 changes: 0 additions & 3 deletions request/graphql/schema/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ const (
ExplainArgExecute string = "execute"
ExplainArgDebug string = "debug"

DocID string = "docID"
DocIDs string = "docIDs"

IndexDirectiveLabel = "index"
IndexDirectivePropName = "name"
IndexDirectivePropFields = "fields"
Expand Down
4 changes: 2 additions & 2 deletions tests/bench/query/simple/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func runQueryBenchGetSync(
}

func formatQuery(b *testing.B, query string, dockeys [][]client.DocKey) string {
numPlaceholders := strings.Count(query, "{{dockey}}")
numPlaceholders := strings.Count(query, "{{docID}}")
if numPlaceholders == 0 {
return query
}
Expand Down Expand Up @@ -119,7 +119,7 @@ func formatQuery(b *testing.B, query string, dockeys [][]client.DocKey) string {
dockeysCopy = append(dockeysCopy[:rIndex], dockeysCopy[rIndex+1:]...)

// replace
query = strings.Replace(query, "{{dockey}}", key.String(), 1)
query = strings.Replace(query, "{{docID}}", key.String(), 1)
}

// b.Logf("Query After: %s", query)
Expand Down
4 changes: 2 additions & 2 deletions tests/bench/query/simple/with_multi_lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
)

var (
// 10x dockey will be replaced in the bench runner func
// 10x `docID`s will be replaced in the bench runner func
userSimpleWithMultiLookupQuery = `
query {
User(dockeys: ["{{dockey}}", "{{dockey}}", "{{dockey}}", "{{dockey}}", "{{dockey}}", "{{dockey}}", "{{dockey}}", "{{dockey}}", "{{dockey}}", "{{dockey}}"]) {
User(docIDs: ["{{docID}}", "{{docID}}", "{{docID}}", "{{docID}}", "{{docID}}", "{{docID}}", "{{docID}}", "{{docID}}", "{{docID}}", "{{docID}}"]) {
_docID
Name
Age
Expand Down
4 changes: 2 additions & 2 deletions tests/bench/query/simple/with_single_lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
)

var (
// dockey will be replaced in the bench runner func
// The `docID` will be replaced in the bench runner func
userSimpleWithSingleLookupQuery = `
query {
User(dockey: "{{dockey}}") {
User(docID: "{{docID}}") {
_docID
Name
Age
Expand Down
18 changes: 9 additions & 9 deletions tests/integration/explain/debug/dagscan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestDebugExplainCommitsDagScanQueryOp(t *testing.T) {
testUtils.ExplainRequest{

Request: `query @explain(type: debug) {
commits (dockey: "bae-41598f0c-19bc-5da6-813b-e80f14a10df3", fieldId: "1") {
commits (docID: "bae-41598f0c-19bc-5da6-813b-e80f14a10df3", fieldId: "1") {
links {
cid
}
Expand All @@ -56,15 +56,15 @@ func TestDebugExplainCommitsDagScanQueryOp(t *testing.T) {
func TestDebugExplainCommitsDagScanQueryOpWithoutField(t *testing.T) {
test := testUtils.TestCase{

Description: "Explain (debug) commits query-op with only dockey (no field).",
Description: "Explain (debug) commits query-op with only docID (no field).",

Actions: []any{
explainUtils.SchemaForExplainTests,

testUtils.ExplainRequest{

Request: `query @explain(type: debug) {
commits (dockey: "bae-41598f0c-19bc-5da6-813b-e80f14a10df3") {
commits (docID: "bae-41598f0c-19bc-5da6-813b-e80f14a10df3") {
links {
cid
}
Expand All @@ -90,7 +90,7 @@ func TestDebugExplainLatestCommitsDagScanQueryOp(t *testing.T) {
testUtils.ExplainRequest{

Request: `query @explain(type: debug) {
latestCommits(dockey: "bae-41598f0c-19bc-5da6-813b-e80f14a10df3", fieldId: "1") {
latestCommits(docID: "bae-41598f0c-19bc-5da6-813b-e80f14a10df3", fieldId: "1") {
cid
links {
cid
Expand All @@ -109,15 +109,15 @@ func TestDebugExplainLatestCommitsDagScanQueryOp(t *testing.T) {
func TestDebugExplainLatestCommitsDagScanQueryOpWithoutField(t *testing.T) {
test := testUtils.TestCase{

Description: "Explain (debug) latestCommits query-op with only dockey (no field).",
Description: "Explain (debug) latestCommits query-op with only docID (no field).",

Actions: []any{
explainUtils.SchemaForExplainTests,

testUtils.ExplainRequest{

Request: `query @explain(type: debug) {
latestCommits(dockey: "bae-41598f0c-19bc-5da6-813b-e80f14a10df3") {
latestCommits(docID: "bae-41598f0c-19bc-5da6-813b-e80f14a10df3") {
cid
links {
cid
Expand All @@ -136,7 +136,7 @@ func TestDebugExplainLatestCommitsDagScanQueryOpWithoutField(t *testing.T) {
func TestDebugExplainLatestCommitsDagScanWithoutDocKey_Failure(t *testing.T) {
test := testUtils.TestCase{

Description: "Explain (debug) latestCommits query without DocKey.",
Description: "Explain (debug) latestCommits query without docID.",

Actions: []any{
explainUtils.SchemaForExplainTests,
Expand All @@ -152,7 +152,7 @@ func TestDebugExplainLatestCommitsDagScanWithoutDocKey_Failure(t *testing.T) {
}
}`,

ExpectedError: "Field \"latestCommits\" argument \"dockey\" of type \"ID!\" is required but not provided.",
ExpectedError: "Field \"latestCommits\" argument \"docID\" of type \"ID!\" is required but not provided.",
},
},
}
Expand All @@ -179,7 +179,7 @@ func TestDebugExplainLatestCommitsDagScanWithoutAnyArguments_Failure(t *testing.
}
}`,

ExpectedError: "Field \"latestCommits\" argument \"dockey\" of type \"ID!\" is required but not provided.",
ExpectedError: "Field \"latestCommits\" argument \"docID\" of type \"ID!\" is required but not provided.",
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
func TestDebugExplainRequestWithDockeysOnInnerGroupSelection(t *testing.T) {
test := testUtils.TestCase{

Description: "Explain (debug) request with dockeys on inner _group.",
Description: "Explain (debug) request with docIDs on inner _group.",

Actions: []any{
explainUtils.SchemaForExplainTests,
Expand All @@ -32,7 +32,7 @@ func TestDebugExplainRequestWithDockeysOnInnerGroupSelection(t *testing.T) {
groupBy: [age]
) {
age
_group(dockeys: ["bae-6a4c5bc5-b044-5a03-a868-8260af6f2254"]) {
_group(docIDs: ["bae-6a4c5bc5-b044-5a03-a868-8260af6f2254"]) {
name
}
}
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/explain/debug/group_with_dockey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
func TestDebugExplainRequestWithDockeyOnParentGroupBy(t *testing.T) {
test := testUtils.TestCase{

Description: "Explain (debug) request with a dockey on parent groupBy.",
Description: "Explain (debug) request with a document ID on parent groupBy.",

Actions: []any{
explainUtils.SchemaForExplainTests,
Expand All @@ -30,7 +30,7 @@ func TestDebugExplainRequestWithDockeyOnParentGroupBy(t *testing.T) {
Request: `query @explain(type: debug) {
Author(
groupBy: [age],
dockey: "bae-6a4c5bc5-b044-5a03-a868-8260af6f2254"
docID: "bae-6a4c5bc5-b044-5a03-a868-8260af6f2254"
) {
age
_group {
Expand All @@ -50,7 +50,7 @@ func TestDebugExplainRequestWithDockeyOnParentGroupBy(t *testing.T) {
func TestDebugExplainRequestWithDockeysAndFilterOnParentGroupBy(t *testing.T) {
test := testUtils.TestCase{

Description: "Explain (debug) request with dockeys and filter on parent groupBy.",
Description: "Explain (debug) request with document IDs and filter on parent groupBy.",

Actions: []any{
explainUtils.SchemaForExplainTests,
Expand All @@ -61,7 +61,7 @@ func TestDebugExplainRequestWithDockeysAndFilterOnParentGroupBy(t *testing.T) {
Author(
groupBy: [age],
filter: {age: {_eq: 20}},
dockeys: [
docIDs: [
"bae-6a4c5bc5-b044-5a03-a868-8260af6f2254",
"bae-4ea9d148-13f3-5a48-a0ef-9ffd344caeed"
]
Expand Down
Loading

0 comments on commit 3ad518e

Please sign in to comment.