diff --git a/mongo/mongo_test.go b/mongo/mongo_test.go index 3f365141ccb2093a4bce34f2db798f1018f50643..62d338a703d3fe9398c71f1643f7f8c6b3f2d4f8 100644 --- a/mongo/mongo_test.go +++ b/mongo/mongo_test.go @@ -3,6 +3,7 @@ package mongo import ( "fmt" "github.com/gosexy/db" + "github.com/gosexy/dig" "github.com/gosexy/to" "github.com/kr/pretty" "labix.org/v2/mgo/bson" @@ -581,6 +582,20 @@ func TestRelation(t *testing.T) { ) fmt.Printf("relations (1) %# v\n", pretty.Formatter(results)) + + var testv string + + testv = dig.String(&results, 0, "lives_in", "name") + + if testv == "" { + t.Fatalf("Test failed, expected some value.") + } + + testv = dig.String(&results, 1, "has_children", 2, "name") + + if testv == "" { + t.Fatalf("Test failed, expected some value.") + } } // Tests relations between collections using structs. diff --git a/mysql/mysql_test.go b/mysql/mysql_test.go index 4d06631abfa006b7da7939b19b45123ff9a13a83..4dc45ee21c6800799166c0d67325ac36587c61eb 100644 --- a/mysql/mysql_test.go +++ b/mysql/mysql_test.go @@ -3,6 +3,7 @@ package mysql import ( "fmt" "github.com/gosexy/db" + "github.com/gosexy/dig" "github.com/gosexy/to" "github.com/kr/pretty" "math/rand" @@ -490,6 +491,20 @@ func TestRelation(t *testing.T) { ) fmt.Printf("relations (1) %# v\n", pretty.Formatter(results)) + + var testv string + + testv = dig.String(&results, 0, "lives_in", "name") + + if testv == "" { + t.Fatalf("Test failed, expected some value.") + } + + testv = dig.String(&results, 1, "has_children", 2, "name") + + if testv == "" { + t.Fatalf("Test failed, expected some value.") + } } // Tests relations between collections using structs. diff --git a/postgresql/postgresql_test.go b/postgresql/postgresql_test.go index 11e500720e5fb35fb81bbf280941ec25e1b3cd2f..28805749bac4e50370a6332dee7ac2e34872ccf7 100644 --- a/postgresql/postgresql_test.go +++ b/postgresql/postgresql_test.go @@ -3,6 +3,7 @@ package postgresql import ( "fmt" "github.com/gosexy/db" + "github.com/gosexy/dig" "github.com/gosexy/to" "github.com/kr/pretty" "math/rand" @@ -490,6 +491,20 @@ func TestRelation(t *testing.T) { ) fmt.Printf("relations (1) %# v\n", pretty.Formatter(results)) + + var testv string + + testv = dig.String(&results, 0, "lives_in", "name") + + if testv == "" { + t.Fatalf("Test failed, expected some value.") + } + + testv = dig.String(&results, 1, "has_children", 2, "name") + + if testv == "" { + t.Fatalf("Test failed, expected some value.") + } } // Tests relations between collections using structs. diff --git a/sqlite/sqlite_test.go b/sqlite/sqlite_test.go index dde0fd7c348c8fc4ac76c0cd86c6ffd06da0ce5c..6ad9a09f78d3f611559c630d8ff5bb7776e41b9a 100644 --- a/sqlite/sqlite_test.go +++ b/sqlite/sqlite_test.go @@ -3,6 +3,7 @@ package sqlite import ( "fmt" "github.com/gosexy/db" + "github.com/gosexy/dig" "github.com/gosexy/to" "github.com/kr/pretty" "math/rand" @@ -481,6 +482,20 @@ func TestRelation(t *testing.T) { ) fmt.Printf("relations (1) %# v\n", pretty.Formatter(results)) + + var testv string + + testv = dig.String(&results, 0, "lives_in", "name") + + if testv == "" { + t.Fatalf("Test failed, expected some value.") + } + + testv = dig.String(&results, 1, "has_children", 2, "name") + + if testv == "" { + t.Fatalf("Test failed, expected some value.") + } } // Tests relations between collections using structs. diff --git a/util/main.go b/util/main.go index c515be3002d3551a31fda1cee991d1db2858c3d5..c78eb597195923dd7194a7a12081114777086744 100644 --- a/util/main.go +++ b/util/main.go @@ -216,7 +216,7 @@ func fetchItemRelations(itemv reflect.Value, relations []db.Relation, convertFn err = res.All(&items) p = reflect.ValueOf(items) } else { - var item []map[string]interface{} + var item map[string]interface{} err = res.One(&item) p = reflect.ValueOf(item) }