Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't call func LoadPolicy by using tablePrefix #23

Closed
riceChuang opened this issue Sep 25, 2019 · 5 comments
Closed

Can't call func LoadPolicy by using tablePrefix #23

riceChuang opened this issue Sep 25, 2019 · 5 comments
Assignees
Labels

Comments

@riceChuang
Copy link
Contributor

first i init an enforcer by using tablePrefix

cas, _ := casbin.NewEnforcer(modelPath)

adapter, err := gormadapter.NewAdapterByDBUsePrefix(db, "test_")
if err != nil {
	panic(err)
}

cas.SetAdapter(adapter)

then i call func cas.LoadPolicy(), that won't found any policy cuz it search db.casbin_rule
not db.test_casbin_rule

here is the code

// LoadPolicy loads policy from database.
func (a *Adapter) LoadPolicy(model model.Model) error {
	var lines []CasbinRule   // this line 
	if err := a.db.Find(&lines).Error; err != nil {
		return err
	}

	for _, line := range lines {
		loadPolicyLine(line, model)
	}

	return nil
}
@riceChuang riceChuang changed the title Can't not call func LoadPolicy by using tablePrefix Can't call func LoadPolicy by using tablePrefix Sep 25, 2019
@hsluoyz
Copy link
Member

hsluoyz commented Sep 25, 2019

Please send a PR.

@riceChuang
Copy link
Contributor Author

Would it be possible to bump the version and perform a new release?

@hsluoyz
Copy link
Member

hsluoyz commented Sep 27, 2019

When your PR is merged, I will bump the version and release it.

@riceChuang
Copy link
Contributor Author

it already merge in
#24

@hsluoyz
Copy link
Member

hsluoyz commented Sep 27, 2019

@hsluoyz hsluoyz closed this as completed Sep 27, 2019
@hsluoyz hsluoyz self-assigned this Sep 27, 2019
@hsluoyz hsluoyz added the bug label Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants