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"` TaskParams MapStringAnyField `db:"task_params" json:"task_params"`
} }
func (alias *IntegrationAlias) ToAlias() Alias { func (alias IntegrationAlias) ToAlias() Alias {
return Alias{ return Alias{
ID: alias.ID, ID: alias.ID,
Alias: alias.Alias, Alias: alias.Alias,

View File

@ -43,6 +43,16 @@ type BoltDb struct {
integrationAlias publicAlias integrationAlias publicAlias
} }
func CreateBoltDB() *BoltDb {
res := BoltDb{}
res.integrationAlias = publicAlias{
aliasProps: db.IntegrationAliasProps,
publicAliasProps: integrationAliasProps,
db: &res,
}
return &res
}
type objectID interface { type objectID interface {
ToBytes() []byte ToBytes() []byte
} }

View File

@ -47,7 +47,7 @@ func (d *publicAlias) createAlias(aliasObj interface{}) (newAlias interface{}, e
return return
} }
_, err = d.db.createObject(-1, d.aliasProps, aliasObj) _, err = d.db.createObject(-1, d.publicAliasProps, aliasObj)
if err != nil { if err != nil {
_ = d.deleteIntegrationAlias(alias.ProjectID, alias.ID) _ = 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) { func (d *publicAlias) deleteIntegrationAlias(projectID int, aliasID int) (err error) {
aliasPtr := reflect.New(d.aliasProps.Type)
aliasObj := reflect.New(d.aliasProps.Type).Interface() aliasObj := aliasPtr.Elem().Interface()
alias := aliasObj.(db.Aliasable).ToAlias() 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 { if err != nil {
return return
} }

View File

@ -16,7 +16,7 @@ func CreateStore() db.Store {
case util.DbDriverMySQL: case util.DbDriverMySQL:
return &sql.SqlDb{} return &sql.SqlDb{}
case util.DbDriverBolt: case util.DbDriverBolt:
return &bolt.BoltDb{} return bolt.CreateBoltDB()
case util.DbDriverPostgres: case util.DbDriverPostgres:
return &sql.SqlDb{} return &sql.SqlDb{}
default: default: