Skip to content

Commit

Permalink
Reverse args order to lid()
Browse files Browse the repository at this point in the history
  • Loading branch information
sam boyer committed Jul 23, 2023
1 parent 7124f98 commit 5d824ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type lensID struct {
From, To SyntacticVersion
}

func lid(to, from SyntacticVersion) lensID {
func lid(from, to SyntacticVersion) lensID {
return lensID{from, to}
}

Expand Down Expand Up @@ -218,7 +218,7 @@ func (ml *maybeLineage) checkGoLensCompleteness() error {
// TODO(sdboyer) it'd be nice to consolidate all the errors so that the user always sees a complete set of problems
all := make(map[lensID]bool)
for _, lens := range ml.implens {
id := lid(lens.To, lens.From)
id := lid(lens.From, lens.To)
if all[id] {
return fmt.Errorf("duplicate Go migration %s", id)
}
Expand All @@ -234,7 +234,7 @@ func (ml *maybeLineage) checkGoLensCompleteness() error {
for _, sch := range ml.schlist[1:] {
// there must always at least be a reverse lens
v := sch.Version()
revid := lid(prior, v)
revid := lid(v, prior)

if !all[revid] {
missing = append(missing, revid)
Expand All @@ -244,7 +244,7 @@ func (ml *maybeLineage) checkGoLensCompleteness() error {

if v[0] != prior[0] {
// if we crossed a major version, there must also be a forward lens
fwdid := lid(v, prior)
fwdid := lid(prior, v)
if !all[fwdid] {
missing = append(missing, fwdid)
} else {
Expand Down Expand Up @@ -272,7 +272,7 @@ func (ml *maybeLineage) checkGoLensCompleteness() error {
// walk the slice so output is reliably ordered
for _, lens := range ml.implens {
// if it's not in the list it's because it was expected & already processed
elid := lid(lens.To, lens.From)
elid := lid(lens.From, lens.To)
if _, has := all[elid]; !has {
continue
}
Expand Down Expand Up @@ -301,7 +301,7 @@ func (ml *maybeLineage) checkGoLensCompleteness() error {

ml.lensmap = make(map[lensID]ImperativeLens, len(ml.implens))
for _, lens := range ml.implens {
ml.lensmap[lid(lens.To, lens.From)] = lens
ml.lensmap[lid(lens.From, lens.To)] = lens
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func (i *Instance) translateGo(to SyntacticVersion) (*Instance, TranslationLacun
var err error
if to.Less(from) || sch.Version()[0] != nsch.Version()[0] {
// Going backward, or crossing major version - need explicit lens
mlid := lid(nsch.Version(), sch.Version())
mlid := lid(sch.Version(), nsch.Version())
rti, err = lensmap[mlid].Mapper(ti, nsch)
if err != nil {
return nil, nil, fmt.Errorf("error executing %s migration: %w", mlid, err)
Expand Down

0 comments on commit 5d824ad

Please sign in to comment.