Permalink
Browse files

Fixing test.

  • Loading branch information...
1 parent 5d4c845 commit 7a2b5aab849df112f2278ab94852f33f360c9c72 @xiam xiam committed Sep 21, 2012
Showing with 22 additions and 9 deletions.
  1. +1 −3 mongo/mongo_test.go
  2. BIN sqlite/dumps/gotest.sqlite3.db
  3. +18 −3 sqlite/sqlite.go
  4. +3 −3 sqlite/sqlite_test.go
View
@@ -328,14 +328,12 @@ func TestDataTypes(t *testing.T) {
delete(item, "_id")
- ids, err := col.Append(item)
+ _, err = col.Append(item)
if err != nil {
t.Errorf("Could not append second element.")
}
- fmt.Printf("%v\n", ids)
-
// Testing rows
items := col.FindAll()
Binary file not shown.
View
@@ -652,7 +652,9 @@ func toNative(val interface{}) interface{} {
}
// Inserts rows into the currently active table.
-func (t *SqliteTable) Append(items ...interface{}) error {
+func (t *SqliteTable) Append(items ...interface{}) ([]db.Id, error) {
+
+ ids := []db.Id{}
itop := len(items)
@@ -677,13 +679,26 @@ func (t *SqliteTable) Append(items ...interface{}) error {
slValues(values),
)
+ res, _ := t.parent.slExec(
+ "Query",
+ "SELECT LAST_INSERT_ROWID()",
+ )
+
+ var lastId string
+
+ res.Next()
+
+ res.Scan(&lastId)
+
+ ids = append(ids, db.Id(lastId))
+
if err != nil {
- return err
+ return ids, err
}
}
- return nil
+ return ids, nil
}
// Returns a SQLite table structure by name.
View
@@ -284,7 +284,7 @@ func TestDataTypes(t *testing.T) {
data := getTestData()
- err = col.Append(data)
+ _, err = col.Append(data)
if err != nil {
t.Errorf("Could not append test data.")
@@ -293,15 +293,15 @@ func TestDataTypes(t *testing.T) {
// Getting and reinserting.
item := col.Find()
- err = col.Append(item)
+ _, err = col.Append(item)
if err == nil {
t.Errorf("Expecting duplicated-key error.")
}
delete(item, "id")
- err = col.Append(item)
+ _, err = col.Append(item)
if err != nil {
t.Errorf("Could not append second element.")

0 comments on commit 7a2b5aa

Please sign in to comment.