Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing test.

  • Loading branch information...
commit 7a2b5aab849df112f2278ab94852f33f360c9c72 1 parent 5d4c845
@xiam xiam authored
View
4 mongo/mongo_test.go
@@ -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()
View
BIN  sqlite/dumps/gotest.sqlite3.db
Binary file not shown
View
21 sqlite/sqlite.go
@@ -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
6 sqlite/sqlite_test.go
@@ -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,7 +293,7 @@ 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.")
@@ -301,7 +301,7 @@ func TestDataTypes(t *testing.T) {
delete(item, "id")
- err = col.Append(item)
+ _, err = col.Append(item)
if err != nil {
t.Errorf("Could not append second element.")
Please sign in to comment.
Something went wrong with that request. Please try again.