diff --git a/server/mapobjectdb/sqlite_mapobjects.go b/server/mapobjectdb/sqlite_mapobjects.go index 0aa0adf..f059342 100644 --- a/server/mapobjectdb/sqlite_mapobjects.go +++ b/server/mapobjectdb/sqlite_mapobjects.go @@ -21,7 +21,6 @@ const addMapDataQuery = ` insert into objects(x,y,z,posx,posy,posz,type,mtime) values(?, ?, ?, ?, ?, ?, ?, ?) -returning id ` const addMapDataAttributeQuery = ` @@ -64,7 +63,7 @@ func (db *Sqlite3Accessor) AddMapData(data MapObject) error { return err } } - + tx.Commit() return nil } diff --git a/server/mapobjectdb/sqlite_test.go b/server/mapobjectdb/sqlite_test.go index eca3b2e..3f90f8c 100644 --- a/server/mapobjectdb/sqlite_test.go +++ b/server/mapobjectdb/sqlite_test.go @@ -63,3 +63,43 @@ func TestMigrate(t *testing.T) { } } + + +func TestMapObjects(t *testing.T) { + tmpfile, err := ioutil.TempFile("", "TestMapObjects.*.sqlite") + if err != nil { + panic(err) + } + defer os.Remove(tmpfile.Name()) + + db, err := NewSqliteAccessor(tmpfile.Name()) + if err != nil { + panic(err) + } + + err = db.Migrate() + if err != nil { + panic(err) + } + + attrs := make(map[string]string) + attrs["X"] = "y" + + pos := coords.NewMapBlockCoords(0,0,0) + + o := MapObject{ + MBPos: &pos, + X: 1, + Y: 2, + Z: 3, + Type: "xy", + Mtime: 1234, + Attributes: attrs, + } + + err = db.AddMapData(o) + if err != nil { + panic(err) + } + +}