-
-
Notifications
You must be signed in to change notification settings - Fork 206
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
add default TableName of NewAdapterByDB() #51
Conversation
Signed-off-by: miaolz123 <miaolizhao@126.com>
Signed-off-by: miaolz123 <miaolizhao@126.com>
Signed-off-by: miaolz123 <miaolizhao@126.com>
from #50 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -184,8 +184,8 @@ func openDBConnection(driverName, dataSourceName string) (*gorm.DB, error) { | |||
db, err = gorm.Open(postgres.Open(dataSourceName), &gorm.Config{}) | |||
} else if driverName == "mysql" { | |||
db, err = gorm.Open(mysql.Open(dataSourceName), &gorm.Config{}) | |||
//} else if driverName == "sqlite3" { | |||
// db, err = gorm.Open(sqlite.Open(dataSourceName), &gorm.Config{}) | |||
//} else if driverName == "sqlite3" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change of these lines is just for code format.
// Example: gormadapter.NewAdapterByDBUseTableName(&db, "cms", "casbin") Automatically generate table name like this "cms_casbin" | ||
func NewAdapterByDBUseTableName(db *gorm.DB, prefix string,tablename string) (*Adapter, error) { | ||
func NewAdapterByDBUseTableName(db *gorm.DB, prefix string, tablename string) (*Adapter, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to NewAdapterByDBWithTableName()
, arg to tableName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the change of this line is just for code format and I have no plans to unify code-style at this PR.
@@ -148,14 +151,19 @@ func NewAdapter(driverName string, dataSourceName string,params ...interface{}) | |||
return a, nil | |||
} | |||
|
|||
// NewAdapterByDB obtained through an existing Gorm instance get a adapter, specify the table prefix and the table name | |||
// NewAdapterByDBUseTableName obtained through an existing Gorm instance get a adapter, specify the table prefix and the table name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obtained through an existing Gorm instance get a adapter
This sentense doesn't make sense. Change it to smooth English.
@@ -164,17 +172,9 @@ func NewAdapterByDBUseTableName(db *gorm.DB, prefix string,tablename string) (*A | |||
return a, nil | |||
} | |||
|
|||
// NewAdapterByDB obtained through an existing Gorm instance get a adapter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obtained through an existing Gorm instance get a adapter
This sentense doesn't make sense. Change it to smooth English.
@miaolz123 reviewed. |
To be honest, I submitted this PR only to fix default table name bug which make the access-control of my project doesn't work right. Due to the limited free time, I have no plans to unify code-style and commet-spell at this PR. please close this PR if you think my modified code is unacceptable. I can accept it totally. |
This PR is acceptable. I just found some other places that can be improved. I will find others to finish what I proposed. Thanks. |
@00LT00 please send a new PR to fix what I have commented in this PR. |
ok |
@00LT00 you can first create an issue to track this. |
No description provided.