Skip to content

Commit

Permalink
PR: Fix the 1.22 todos
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzadlone committed Aug 15, 2024
1 parent 284a1d3 commit ce3b906
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
6 changes: 1 addition & 5 deletions internal/lens/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,7 @@ func getCollectionHistory(
history := map[schemaVersionID]*collectionHistoryLink{}
schemaVersionsByColID := map[uint32]schemaVersionID{}

for _, c := range cols {
// Todo - this `col := c` can be removed with Go 1.22:
// https://github.com/sourcenetwork/defradb/issues/2431
col := c

for _, col := range cols {
// Convert the temporary types to the cleaner return type:
history[col.SchemaVersionID] = &collectionHistoryLink{
collection: &col,

Check failure on line 163 in internal/lens/history.go

View workflow job for this annotation

GitHub Actions / Lint GoLang job

exporting a pointer for the loop variable col (exportloopref)
Expand Down
5 changes: 2 additions & 3 deletions internal/planner/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,8 @@ func (n *dagScanNode) Next() (bool, error) {
// so that the last new cid will be at the front of the slice
n.queuedCids = append(make([]*cid.Cid, len(heads)), n.queuedCids...)

for i, h := range heads {
link := h // TODO remove when Go 1.22 #2431
n.queuedCids[len(heads)-i-1] = &link.Cid
for i, head := range heads {
n.queuedCids[len(heads)-i-1] = &head.Cid

Check failure on line 245 in internal/planner/commit.go

View workflow job for this annotation

GitHub Actions / Lint GoLang job

exporting a pointer for the loop variable head (exportloopref)
}
}

Expand Down
14 changes: 3 additions & 11 deletions internal/request/graphql/schema/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,7 @@ func (g *Generator) buildTypes(
// get all the defined types from the AST
objs := make([]*gql.Object, 0)

for _, c := range collections {
// Copy the loop variable before usage within the loop or it
// will be reassigned before the thunk is run
// TODO remove when Go 1.22
collection := c
for _, collection := range collections {
fieldDescriptions := collection.GetFields()
isEmbeddedObject := !collection.Description.Name.HasValue()
isQuerySource := len(collection.Description.QuerySources()) > 0
Expand Down Expand Up @@ -536,18 +532,14 @@ func (g *Generator) buildTypes(
// buildMutationInputTypes creates the input object types
// for collection create and update mutation operations.
func (g *Generator) buildMutationInputTypes(collections []client.CollectionDefinition) error {
for _, c := range collections {
if !c.Description.Name.HasValue() {
for _, collection := range collections {
if !collection.Description.Name.HasValue() {
// If the definition's collection is empty, this must be a collectionless
// schema, in which case users cannot mutate documents through it and we
// have no need to build mutation input types for it.
continue
}

// Copy the loop variable before usage within the loop or it
// will be reassigned before the thunk is run
// TODO remove when Go 1.22
collection := c
mutationInputName := collection.Description.Name.Value() + mutationInputNameSuffix

// check if mutation input type exists
Expand Down

0 comments on commit ce3b906

Please sign in to comment.