Skip to content

Commit

Permalink
fix: AttributeSelector returns error containing unfound attribute name
Browse files Browse the repository at this point in the history
  • Loading branch information
proullon committed Aug 25, 2023
1 parent 71d06ed commit 8cb2915
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 9 additions & 0 deletions driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ func TestSelectCamelCase(t *testing.T) {
if err != nil {
t.Fatalf("sql.Query CamelCase error : %s", err)
}

_, err = db.Query(`SELECT TestCamelCase, nope, email_snake FROM account WHERE 1`)
if err == nil {
t.Fatalf("expected attribute not found error")
}
ee := "attribute not defined: account.nope"
if err.Error() != ee {
t.Fatalf("expected error to be '%s', got '%s'", ee, err.Error())
}
}

func TestSelectSimplePredicate(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions engine/agnostic/relation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package agnostic

import (
"container/list"
"errors"
"fmt"
"strings"
"sync"
Expand Down Expand Up @@ -61,7 +60,7 @@ func (r *Relation) Attribute(name string) (int, Attribute, error) {
name = strings.ToLower(name)
index, ok := r.attrIndex[name]
if !ok {
return 0, Attribute{}, errors.New("attribute not defined")
return 0, Attribute{}, fmt.Errorf("attribute not defined: %s.%s", r.name, name)
}
return index, r.attributes[index], nil
}
Expand Down

0 comments on commit 8cb2915

Please sign in to comment.