8000 Issue 329 by HuangWeiCen · Pull Request #385 · actiontech/sqle · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Issue 329 #385

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

Merged
merged 13 commits into from
Mar 11, 2022
Merged

Issue 329 #385

merged 13 commits into from
Mar 11, 2022

Conversation

HuangWeiCen
Copy link
Contributor

@@ -23,13 +24,20 @@ type Instance struct {
SecretPassword string `json:"secret_password" gorm:"column:db_password; not null"`
Desc string `json:"desc" example:"this is a instance"`
WorkflowTemplateId uint `json:"workflow_template_id"`
AdditionalParams string `json:"additional_params" gorm:"type:text"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用通用的model层params 结构

@@ -141,7 +146,7 @@ type handler func(log *logrus.Entry, c *Config) (Driver, error)
//
// Register makes a database driver available by the provided driver name.
// Driver's initialize handler and audit rules register by Register.
func Register(name string, h handler, rs []*Rule) {
func Register(name string, h handler, rs []*Rule, ap []*params.Param) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

考虑兼容性

additionalParams := driver.AllAdditionalParams()[req.DBType]
for _, param := range additionalParams {
for _, additionalParam := range req.AdditionalParams {
if param.Key == additionalParam.Name {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用SetParamValue 赋值,里面封装了类型验证

additionalParams := driver.AllAdditionalParams()[req.DBType]
for _, param := range additionalParams {
for _, additionalParam := range req.AdditionalParams {
if param.Key == additionalParam.Name {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用SetParamValue 赋值,里面封装了类型验证

return c.JSON(http.StatusOK, res)
}

func ParamsSliceToInstanceAdditionalParamResV1Slice(params []*params.Param) []*InstanceAdditionalParamResV1 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convertParamsToInstanceAdditionalParamRes ?

Port string
User string
Password string
AdditionalParams []*params.Param
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用 params.Params 保持统一

@@ -27,6 +29,8 @@ type Adaptor struct {
ruleToRawHandler map[string] /*rule name*/ rawSQLRuleHandler
ruleToASTHandler map[string] /*rule name*/ astSQLRuleHandler

additionalParams []*params.Param
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用 params.Params 保持统一

@@ -163,6 +174,10 @@ func (r *registererImpl) Rules() []*driver.Rule {
return r.rules
}

func (r *registererImpl) AdditionalParams() []*params.Param {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用 params.Params 保持统一

"github.com/actiontech/sqle/sqle/pkg/params"
)

func ParamToProtoParam(p []*params.Param) []*Param {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ParamToProtoParam 语法上是什么意思

@@ -198,14 +237,15 @@ type GetInstanceResV1 struct {
Data InstanceResV1 `json:"data"`
}

func convertInstanceToRes(instance *model.Instance) InstanceResV1 {
func convertInstanceToRes(instance *model.Instance, p []*params.Param) InstanceResV1 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用 params.Params 保持统一

@sjjian sjjian merged commit a57213f into main Mar 11, 2022
@sjjian sjjian deleted the issue_329_1 branch March 11, 2022 08:57
taolx0 pushed a commit that referenced this pull request Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0