diff --git a/db/Integration.go b/db/Integration.go index 2e35a31d..c2903746 100644 --- a/db/Integration.go +++ b/db/Integration.go @@ -84,7 +84,7 @@ type Integration struct { TaskParams MapStringAnyField `db:"task_params" json:"task_params"` } -func (alias *IntegrationAlias) ToAlias() Alias { +func (alias IntegrationAlias) ToAlias() Alias { return Alias{ ID: alias.ID, Alias: alias.Alias, diff --git a/db/bolt/BoltDb.go b/db/bolt/BoltDb.go index 3c058b6e..ebd794b8 100644 --- a/db/bolt/BoltDb.go +++ b/db/bolt/BoltDb.go @@ -43,6 +43,16 @@ type BoltDb struct { integrationAlias publicAlias } +func CreateBoltDB() *BoltDb { + res := BoltDb{} + res.integrationAlias = publicAlias{ + aliasProps: db.IntegrationAliasProps, + publicAliasProps: integrationAliasProps, + db: &res, + } + return &res +} + type objectID interface { ToBytes() []byte } diff --git a/db/bolt/public_alias.go b/db/bolt/public_alias.go index 552c417b..0253298f 100644 --- a/db/bolt/public_alias.go +++ b/db/bolt/public_alias.go @@ -47,7 +47,7 @@ func (d *publicAlias) createAlias(aliasObj interface{}) (newAlias interface{}, e return } - _, err = d.db.createObject(-1, d.aliasProps, aliasObj) + _, err = d.db.createObject(-1, d.publicAliasProps, aliasObj) if err != nil { _ = d.deleteIntegrationAlias(alias.ProjectID, alias.ID) @@ -58,12 +58,12 @@ func (d *publicAlias) createAlias(aliasObj interface{}) (newAlias interface{}, e } func (d *publicAlias) deleteIntegrationAlias(projectID int, aliasID int) (err error) { - - aliasObj := reflect.New(d.aliasProps.Type).Interface() + aliasPtr := reflect.New(d.aliasProps.Type) + aliasObj := aliasPtr.Elem().Interface() alias := aliasObj.(db.Aliasable).ToAlias() - err = d.db.getObject(projectID, d.aliasProps, intObjectID(aliasID), &aliasObj) + err = d.db.getObject(projectID, d.aliasProps, intObjectID(aliasID), aliasPtr.Interface()) if err != nil { return } diff --git a/db/factory/store.go b/db/factory/store.go index da0c778f..943645e3 100644 --- a/db/factory/store.go +++ b/db/factory/store.go @@ -16,7 +16,7 @@ func CreateStore() db.Store { case util.DbDriverMySQL: return &sql.SqlDb{} case util.DbDriverBolt: - return &bolt.BoltDb{} + return bolt.CreateBoltDB() case util.DbDriverPostgres: return &sql.SqlDb{} default: