1
0
forked from MTSR/mapserver

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 { func (db *Sqlite3Accessor) AddMapData(data *MapObject) error {
tx, err := db.db.Begin()
if err != nil {
return err
}
res, err := db.db.Exec(addMapDataQuery, res, err := db.db.Exec(addMapDataQuery,
data.X, data.Y, data.Z, data.X, data.Y, data.Z,
data.MBPos.X, data.MBPos.Y, data.MBPos.Z, data.MBPos.X, data.MBPos.Y, data.MBPos.Z,
data.Type, data.Mtime) data.Type, data.Mtime)
if err != nil { if err != nil {
tx.Rollback()
return err return err
} }
id, err := res.LastInsertId() id, err := res.LastInsertId()
if err != nil { if err != nil {
tx.Rollback()
return err return err
} }
@ -58,11 +50,9 @@ func (db *Sqlite3Accessor) AddMapData(data *MapObject) error {
_, err := db.db.Exec(addMapDataAttributeQuery, id, k, v) _, err := db.db.Exec(addMapDataAttributeQuery, id, k, v)
if err != nil { if err != nil {
tx.Rollback()
return err return err
} }
} }
tx.Commit()
return nil return nil
} }

View File

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