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

fix: empty slice found error #164

Closed dirablue closed 2 years ago

dirablue commented 2 years ago

fixed the error occurred when savePolicy is called.

github.com/casbin/gorm-adapter/v3@v3.7.1/adapter.go:580 empty slice found
[3.402ms] [rows:0] INSERT INTO `casbin_rule` (`ptype`,`v0`,`v1`,`v2`,`v3`,`v4`,`v5`,`v6`,`v7`) VALUES 
empty slice found
casbin-bot commented 2 years ago

@tangyang9464 @closetool @sagilio please review

CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.

hsluoyz commented 2 years ago

@tangyang9464

dirablue commented 2 years ago

@hsluoyz hi, are you still waiting for something before merge this?

hsluoyz commented 2 years ago

@dirablue plz sign CLA:

image

dirablue commented 2 years ago

@hsluoyz hi I signed CLA just now. thanks.

hsluoyz commented 2 years ago

@dirablue why do we need to handle the case of empty line? I think it's caller's responsibility to make sure the slice has good format

dirablue commented 2 years ago

@hsluoyz hi lines will be null with some conditions in this code. then Create will be called with null and the error will occur.

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

github-actions[bot] commented 2 years ago

:tada: This PR is included in version 3.7.2 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: