-
-
Notifications
You must be signed in to change notification settings - Fork 203
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 user define database #43
Conversation
Signed-off-by: 00LT00 <lightning@hdu.edu.cn>
Signed-off-by: 00LT00 <lightning@hdu.edu.cn>
@rico-ci please review. |
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.
I generally find that the positional checking of the type of a specific parameter passed in params will eventually turn out to be very fragile. I am not aware of any better patterns in Go specifically. I suppose for now it will do.
On another note, I am wondering if there are cases where only a subset of the three arguments are passed (tableName
, databaseName
, dbSpecified
)?
}else if len(params) == 1 { | ||
switch p1:=params[0].(type) { | ||
case bool: | ||
a.dbSpecified = p1 |
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.
How can one set dbSpecified to True without providing the parameters required for that db?
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.
@rico-ci If I understand correctly, you can just pass in a bool variable as the value of dbSpecified.
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.
When would you encounter the case that dbSpecified is set but not the databaseName or the 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.
When there is no databseName or tableName on the old version, you can set dbspecified separately. So if you dont set dbname and tablename, it will use the default values.
Default values are set in adapter.go#L94-L96
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.
On the other hand, it is also compatible with older versions
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.
@rico-ci Do you have any question?
@00LT00 please fix. |
Once my comments are addressed by @00LT00 I'm happy for this to be merged. Will there be any incompatibilities with casbin-server? Will we have to adapt code there and in other projects using this? |
It is just add two optional parameters. And the default value is same as the old versions. So I think it will work as before. If you have any problems, welcome to create issues. |
ping @rico-ci |
@00LT00 could you format the code? I can merge it to gorm-adapter. |
Signed-off-by: 00LT00 <lightning@zerokirin.online>
Already formatted code @nodece |
Signed-off-by: 00LT00 lightning@hdu.edu.cn
Fix: #40