redis-adapter icon indicating copy to clipboard operation
redis-adapter copied to clipboard

updatePolicies is not supported in redis-adapter

Open sujatapatnaik52 opened this issue 3 years ago • 4 comments

Hi, When I am trying to use updatePolicies API it gives me the following exception:

panic: interface conversion: *redisadapter.Adapter is not persist.UpdatableAdapter: missing method UpdateFilteredPolicies

goroutine 1 [running]:
github.com/casbin/casbin/v2.(*Enforcer).updatePolicies(0xc000144400, {0x6bef5b, 0x1}, {0x6bef5b, 0x1}, {0xc00015c540, 0x2, 0x2}, {0xc00015c570, 0x2, ...})
	/root/go/pkg/mod/github.com/casbin/casbin/[email protected]/internal_api.go:204 +0x11a
github.com/casbin/casbin/v2.(*Enforcer).UpdateNamedPolicies(...)
	/root/go/pkg/mod/github.com/casbin/casbin/[email protected]/management_api.go:253
github.com/casbin/casbin/v2.(*Enforcer).UpdatePolicies(0xc00013dd58?, {0xc00015c540?, 0x6bef5b?, 0x1?}, {0xc00015c570?, 0xc000024240?, 0x20?})
	/root/go/pkg/mod/github.com/casbin/casbin/[email protected]/management_api.go:249 +0x4f
main.(*Role).updatepolicy(0xc00013de18, {0x6bff99, 0x8}, {0x6bf711, 0x6}, 0x0)
	

sujatapatnaik52 avatar Aug 11 '22 10:08 sujatapatnaik52

@tangyang9464 @JalinWang @imp2002

casbin-bot avatar Aug 11 '22 10:08 casbin-bot

@JalinWang

/cc @tangyang9464

hsluoyz avatar Aug 11 '22 12:08 hsluoyz

Changes in the adapter interface cause this: https://github.com/casbin/casbin/commit/e3538fbf41846be5c5d0dbfcfb5149d6b3f8f49e#diff-ccf7c777bfd057d317dca5b3baa62bfdcca0121745391d55bc6bdbcbb2e04c2bR25-R26 Redis-adapter doesn't catch up with it. I'll fix it.

If this block you, you can switch to other adapters first for development, e.g., https://github.com/casbin/xorm-adapter. The migration is easy.

JalinWang avatar Aug 12 '22 08:08 JalinWang

@JalinWang plz implement UpdateFilteredPolicies() for this adapter, or if not possible, provide an empty implementation

hsluoyz avatar Aug 12 '22 12:08 hsluoyz