casbin / gorm-adapter

GORM adapter for Casbin, see extended version of GORM Adapter Ex at: https://github.com/casbin/gorm-adapter-ex
https://github.com/casbin/casbin
Apache License 2.0
692 stars 207 forks source link

there is a problem with the processing of error #189

Closed zhtiyissr closed 1 year ago

zhtiyissr commented 1 year ago

https://github.com/casbin/gorm-adapter/blob/master/adapter.go

func loadPolicyLine(line CasbinRule, model model.Model) error {
    var p = []string{line.Ptype,
        line.V0, line.V1, line.V2,
        line.V3, line.V4, line.V5}

    index := len(p) - 1
    for p[index] == "" {
        index--
    }
    index += 1
    p = p[:index]
    err := persist.LoadPolicyArray(p, model)
    if err != nil {
        return nil
    }
    return err
}

Finally, the processing of error, when the error is not nil, it should return the error itself, otherwise return empty

casbin-bot commented 1 year ago

@tangyang9464 @JalinWang @imp2002

hsluoyz commented 1 year ago

@bbqe1314 this commit: https://github.com/casbin/gorm-adapter/commit/5ffa22b86f0c3c4617929350393bb1137d8f3ddc introduced this bug, can you make a PR to fix it?