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

Return correct error codes for projections #384

Merged
merged 8 commits into from
Mar 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix linters
  • Loading branch information
seeforschauer committed Mar 22, 2022
commit dcbec2eb317bdd7bf5bef19626f2bd904d607c90
12 changes: 8 additions & 4 deletions internal/handlers/common/projection.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ func isProjectionInclusion(projection *types.Document) (inclusion bool, err erro
if v {
if exclusion {
err = NewError(ErrProjectionExclusionInInclusion,
fmt.Errorf("Cannot do exclusion on field array in inclusion projection"))
fmt.Errorf("Cannot do exclusion on field array in inclusion projection"),
)
return
}
inclusion = true
} else {
if inclusion {
err = NewError(ErrProjectionInclusionInExclusion,
fmt.Errorf("Cannot do inclusion on field array in exclusion projection"))
fmt.Errorf("Cannot do inclusion on field array in exclusion projection"),
)
return
}
exclusion = true
Expand All @@ -50,14 +52,16 @@ func isProjectionInclusion(projection *types.Document) (inclusion bool, err erro
if compareScalars(v, int32(0)) == equal {
if inclusion {
err = NewError(ErrProjectionInclusionInExclusion,
fmt.Errorf("Cannot do inclusion on field array in exclusion projection"))
fmt.Errorf("Cannot do inclusion on field array in exclusion projection"),
)
return
}
exclusion = true
} else {
if exclusion {
err = NewError(ErrProjectionExclusionInInclusion,
fmt.Errorf("Cannot do exclusion on field array in inclusion projection"))
fmt.Errorf("Cannot do exclusion on field array in inclusion projection"),
)
return
}
inclusion = true
Expand Down