Repository: proullon/ramsql (go)

Issue:
"attribute not defined" error should state _which_ attribute it can't find
Started to get this error after upgrading from v0.0.1 to v0.1.0:

    "attribute not defined"

It would be helpful to indicate which attribute it missing, e.g.

    attribute not defined: attributeName

Bonus points if it were to also mention the table name, e.g. 

    attribute not defined: table_name.attributeName

Pull request description:
fix: AttributeSelector returns error containing unfound attribute name
close #89 

Patch:
diff --git a/engine/agnostic/relation.go b/engine/agnostic/relation.go
index 5dd3b8d..3703214 100644
--- a/engine/agnostic/relation.go
+++ b/engine/agnostic/relation.go
@@ -2,7 +2,6 @@ package agnostic
 
 import (
 	"container/list"
-	"errors"
 	"fmt"
 	"strings"
 	"sync"
@@ -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
 }


Test patch:
diff --git a/driver/driver_test.go b/driver/driver_test.go
index 43385b2..8130426 100644
--- a/driver/driver_test.go
+++ b/driver/driver_test.go
@@ -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) {