remove tx

This commit is contained in:
NatureFreshMilk 2019-01-24 14:04:52 +01:00
parent f132363342
commit 9a53409af5
2 changed files with 1 additions and 11 deletions

View File

@ -30,26 +30,18 @@ values(?, ?, ?)
`
func (db *Sqlite3Accessor) AddMapData(data *MapObject) error {
tx, err := db.db.Begin()
if err != nil {
return err
}
res, err := db.db.Exec(addMapDataQuery,
data.X, data.Y, data.Z,
data.MBPos.X, data.MBPos.Y, data.MBPos.Z,
data.Type, data.Mtime)
if err != nil {
tx.Rollback()
return err
}
id, err := res.LastInsertId()
if err != nil {
tx.Rollback()
return err
}
@ -58,11 +50,9 @@ func (db *Sqlite3Accessor) AddMapData(data *MapObject) error {
_, err := db.db.Exec(addMapDataAttributeQuery, id, k, v)
if err != nil {
tx.Rollback()
return err
}
}
tx.Commit()
return nil
}

View File

@ -69,7 +69,7 @@ func TestMapObjects(t *testing.T) {
if err != nil {
panic(err)
}
defer os.Remove(tmpfile.Name())
//defer os.Remove(tmpfile.Name())
db, err := NewSqliteAccessor(tmpfile.Name())
if err != nil {