fix(alias): conversation errors

This commit is contained in:
Denis Gukov 2024-12-15 14:08:43 +05:00
parent 2c05436217
commit 821a4148de
No known key found for this signature in database
GPG Key ID: 044381366A5D4731
4 changed files with 16 additions and 6 deletions

View File

@ -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,

View File

@ -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
}

View File

@ -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
}

View File

@ -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: