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

change default v7 to v5 #179

Closed
reckless-huang opened this issue Aug 23, 2022 · 9 comments · Fixed by #181
Closed

change default v7 to v5 #179

reckless-huang opened this issue Aug 23, 2022 · 9 comments · Fixed by #181
Assignees
Labels

Comments

@reckless-huang
Copy link

reckless-huang commented Aug 23, 2022

i want change default v7 struct to v5 ,use NewAdapterByDBWithCustomTable is not work

type CasbinRule struct {
	ID    uint   `gorm:"primaryKey;autoIncrement"`
	Ptype string `gorm:"size:100;uniqueIndex:unique_index"`
	V0    string `gorm:"size:100;uniqueIndex:unique_index"`
	V1    string `gorm:"size:100;uniqueIndex:unique_index"`
	V2    string `gorm:"size:100;uniqueIndex:unique_index"`
	V3    string `gorm:"size:100;uniqueIndex:unique_index"`
	V4    string `gorm:"size:100;uniqueIndex:unique_index"`
	V5    string `gorm:"size:100;uniqueIndex:unique_index"`
}

func InitCasbin() {
	mysqlc := common.CONFIG.Mysqls[0]
	host, port, user, password, database := mysqlc.Host, mysqlc.Port, mysqlc.User, mysqlc.Password, mysqlc.Database
	dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=True&loc=Local", user, password, host, port, database)
	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		common.Log.Error(err.Error())
		return
	}
	gormAdapter.TurnOffAutoMigrate(db)
	a, err := gormAdapter.NewAdapterByDBWithCustomTable(db, &CasbinRule{}, "casbin_rule")
	if err != nil {
		common.Log.Error(err.Error())
		return
	}
	//a, _ := gormAdapter.NewAdapter("mysql", dsn, true)
	e, err := casbin.NewEnforcer(constants.CasbinModel, a)
	if err != nil {
		common.Log.Error(err.Error())
		return
	}
	e.AddFunction("ParamsMatch", ParamsMatchFunc)
```
can you help me , is err here 
Error 1054: Unknown column 'v6' in 'field list'
[73.947ms] [rows:0] INSERT INTO `casbin_rule` (`ptype`,`v0`,`v1`,`v2`,`v3`,`v4`,`v5`,`v6`,`v7`) VALUES ('g','develop','base','','','','','','')
@casbin-bot
Copy link
Member

@hsluoyz
Copy link
Member

hsluoyz commented Aug 23, 2022

We added v6 and v7 because of this issue: #151

@zz541843 can we revert the PR?

@hsluoyz
Copy link
Member

hsluoyz commented Aug 23, 2022

@tangyang9464 what's your opinion?

@JalinWang

@JalinWang
Copy link
Member

Maybe we need to extend #168 to a more flexible schema?

@hsluoyz
Copy link
Member

hsluoyz commented Aug 23, 2022

@JalinWang plz revert PR: #157

@hsluoyz hsluoyz added bug and removed question labels Aug 23, 2022
@tangyang9464
Copy link
Member

Maybe we need to extend #168 to a more flexible schema?

@JalinWang I think so.

@tangyang9464
Copy link
Member

@JalinWang plz revert PR: #157

@hsluoyz I think we should extend #168 to support v7 instead of revert

@reckless-huang
Copy link
Author

@JalinWang plz revert PR: #157

@hsluoyz I think we should extend #168 to support v7 instead of revert

every thanks , what time for merge #168

@hsluoyz
Copy link
Member

hsluoyz commented Aug 26, 2022

@tangyang9464 @JalinWang I still think we should make it simple and just use up to v5 element. The user can fork the library and extend elements as they want. Supporting customizing it will take a lot of efforts for our maintainers team. We may need two weeks to just finish: #180 and this is only one adapter. Remember we have 20+ adapters only for Golang and it will be a disaster to support them all. Not to mention we have 10 more other languages, Java, Python, Node.js, PHP, .NET and each language will have a bunch of adapters. This is something we cannot afford to do with the current development team. Moreover, I don't think it's very meaningful. Just fork it and extend to v7 or v17. It's already so easy. Don't waste tons of our development team's efforts to just fix this small issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants