fix: pass the connector id when workflow database nod… (#599)
This commit is contained in:
parent
f693da17ef
commit
8d1cc2e03a
|
|
@ -64,6 +64,7 @@ func (d *DatabaseRepository) Execute(ctx context.Context, request *nodedatabase.
|
||||||
SQL: &request.SQL,
|
SQL: &request.SQL,
|
||||||
TableType: tableType,
|
TableType: tableType,
|
||||||
UserID: strconv.FormatInt(request.UserID, 10),
|
UserID: strconv.FormatInt(request.UserID, 10),
|
||||||
|
ConnectorID: ptr.Of(request.ConnectorID),
|
||||||
}
|
}
|
||||||
|
|
||||||
req.SQLParams = make([]*database.SQLParamVal, 0, len(request.Params))
|
req.SQLParams = make([]*database.SQLParamVal, 0, len(request.Params))
|
||||||
|
|
@ -106,6 +107,7 @@ func (d *DatabaseRepository) Delete(ctx context.Context, request *nodedatabase.D
|
||||||
OperateType: database.OperateType_Delete,
|
OperateType: database.OperateType_Delete,
|
||||||
TableType: tableType,
|
TableType: tableType,
|
||||||
UserID: strconv.FormatInt(request.UserID, 10),
|
UserID: strconv.FormatInt(request.UserID, 10),
|
||||||
|
ConnectorID: ptr.Of(request.ConnectorID),
|
||||||
}
|
}
|
||||||
|
|
||||||
if request.ConditionGroup != nil {
|
if request.ConditionGroup != nil {
|
||||||
|
|
@ -141,6 +143,7 @@ func (d *DatabaseRepository) Query(ctx context.Context, request *nodedatabase.Qu
|
||||||
OperateType: database.OperateType_Select,
|
OperateType: database.OperateType_Select,
|
||||||
TableType: tableType,
|
TableType: tableType,
|
||||||
UserID: strconv.FormatInt(request.UserID, 10),
|
UserID: strconv.FormatInt(request.UserID, 10),
|
||||||
|
ConnectorID: ptr.Of(request.ConnectorID),
|
||||||
}
|
}
|
||||||
|
|
||||||
req.SelectFieldList = &database.SelectFieldList{FieldID: make([]string, 0, len(request.SelectFields))}
|
req.SelectFieldList = &database.SelectFieldList{FieldID: make([]string, 0, len(request.SelectFields))}
|
||||||
|
|
@ -196,6 +199,7 @@ func (d *DatabaseRepository) Update(ctx context.Context, request *nodedatabase.U
|
||||||
OperateType: database.OperateType_Update,
|
OperateType: database.OperateType_Update,
|
||||||
SQLParams: make([]*database.SQLParamVal, 0),
|
SQLParams: make([]*database.SQLParamVal, 0),
|
||||||
TableType: tableType,
|
TableType: tableType,
|
||||||
|
ConnectorID: ptr.Of(request.ConnectorID),
|
||||||
}
|
}
|
||||||
|
|
||||||
uid := ctxutil.GetUIDFromCtx(ctx)
|
uid := ctxutil.GetUIDFromCtx(ctx)
|
||||||
|
|
@ -243,6 +247,7 @@ func (d *DatabaseRepository) Insert(ctx context.Context, request *nodedatabase.I
|
||||||
OperateType: database.OperateType_Insert,
|
OperateType: database.OperateType_Insert,
|
||||||
TableType: tableType,
|
TableType: tableType,
|
||||||
UserID: strconv.FormatInt(request.UserID, 10),
|
UserID: strconv.FormatInt(request.UserID, 10),
|
||||||
|
ConnectorID: ptr.Of(request.ConnectorID),
|
||||||
}
|
}
|
||||||
|
|
||||||
req.UpsertRows, req.SQLParams, err = resolveUpsertRow(request.Fields)
|
req.UpsertRows, req.SQLParams, err = resolveUpsertRow(request.Fields)
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ type CustomSQLRequest struct {
|
||||||
Params []SQLParam
|
Params []SQLParam
|
||||||
IsDebugRun bool
|
IsDebugRun bool
|
||||||
UserID int64
|
UserID int64
|
||||||
|
ConnectorID int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type Object = map[string]any
|
type Object = map[string]any
|
||||||
|
|
@ -91,6 +92,7 @@ type DeleteRequest struct {
|
||||||
ConditionGroup *ConditionGroup
|
ConditionGroup *ConditionGroup
|
||||||
IsDebugRun bool
|
IsDebugRun bool
|
||||||
UserID int64
|
UserID int64
|
||||||
|
ConnectorID int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type QueryRequest struct {
|
type QueryRequest struct {
|
||||||
|
|
@ -101,6 +103,7 @@ type QueryRequest struct {
|
||||||
OrderClauses []*OrderClause
|
OrderClauses []*OrderClause
|
||||||
IsDebugRun bool
|
IsDebugRun bool
|
||||||
UserID int64
|
UserID int64
|
||||||
|
ConnectorID int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type OrderClause struct {
|
type OrderClause struct {
|
||||||
|
|
@ -113,6 +116,7 @@ type UpdateRequest struct {
|
||||||
Fields map[string]any
|
Fields map[string]any
|
||||||
IsDebugRun bool
|
IsDebugRun bool
|
||||||
UserID int64
|
UserID int64
|
||||||
|
ConnectorID int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type InsertRequest struct {
|
type InsertRequest struct {
|
||||||
|
|
@ -120,6 +124,7 @@ type InsertRequest struct {
|
||||||
Fields map[string]any
|
Fields map[string]any
|
||||||
IsDebugRun bool
|
IsDebugRun bool
|
||||||
UserID int64
|
UserID int64
|
||||||
|
ConnectorID int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDatabaseOperator() DatabaseOperator {
|
func GetDatabaseOperator() DatabaseOperator {
|
||||||
|
|
|
||||||
|
|
@ -423,6 +423,14 @@ func getExecUserID(ctx context.Context) int64 {
|
||||||
return execCtx.RootCtx.ExeCfg.Operator
|
return execCtx.RootCtx.ExeCfg.Operator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getConnectorID(ctx context.Context) int64 {
|
||||||
|
execCtx := execute.GetExeCtx(ctx)
|
||||||
|
if execCtx == nil {
|
||||||
|
panic(fmt.Errorf("unable to get exe context"))
|
||||||
|
}
|
||||||
|
return execCtx.RootCtx.ExeCfg.ConnectorID
|
||||||
|
}
|
||||||
|
|
||||||
func parseToInput(input map[string]any) map[string]any {
|
func parseToInput(input map[string]any) map[string]any {
|
||||||
result := make(map[string]any, len(input))
|
result := make(map[string]any, len(input))
|
||||||
for key, value := range input {
|
for key, value := range input {
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,7 @@ func (c *CustomSQL) Invoke(ctx context.Context, input map[string]any) (map[strin
|
||||||
DatabaseInfoID: c.databaseInfoID,
|
DatabaseInfoID: c.databaseInfoID,
|
||||||
IsDebugRun: isDebugExecute(ctx),
|
IsDebugRun: isDebugExecute(ctx),
|
||||||
UserID: getExecUserID(ctx),
|
UserID: getExecUserID(ctx),
|
||||||
|
ConnectorID: getConnectorID(ctx),
|
||||||
}
|
}
|
||||||
|
|
||||||
inputBytes, err := sonic.Marshal(input)
|
inputBytes, err := sonic.Marshal(input)
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ func (d *Delete) Invoke(ctx context.Context, in map[string]any) (map[string]any,
|
||||||
ConditionGroup: conditionGroup,
|
ConditionGroup: conditionGroup,
|
||||||
IsDebugRun: isDebugExecute(ctx),
|
IsDebugRun: isDebugExecute(ctx),
|
||||||
UserID: getExecUserID(ctx),
|
UserID: getExecUserID(ctx),
|
||||||
|
ConnectorID: getConnectorID(ctx),
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := d.deleter.Delete(ctx, request)
|
response, err := d.deleter.Delete(ctx, request)
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ func (is *Insert) Invoke(ctx context.Context, input map[string]any) (map[string]
|
||||||
Fields: fields,
|
Fields: fields,
|
||||||
IsDebugRun: isDebugExecute(ctx),
|
IsDebugRun: isDebugExecute(ctx),
|
||||||
UserID: getExecUserID(ctx),
|
UserID: getExecUserID(ctx),
|
||||||
|
ConnectorID: getConnectorID(ctx),
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := is.inserter.Insert(ctx, req)
|
response, err := is.inserter.Insert(ctx, req)
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,7 @@ func (ds *Query) Invoke(ctx context.Context, in map[string]any) (map[string]any,
|
||||||
Limit: ds.limit,
|
Limit: ds.limit,
|
||||||
IsDebugRun: isDebugExecute(ctx),
|
IsDebugRun: isDebugExecute(ctx),
|
||||||
UserID: getExecUserID(ctx),
|
UserID: getExecUserID(ctx),
|
||||||
|
ConnectorID: getConnectorID(ctx),
|
||||||
}
|
}
|
||||||
|
|
||||||
req.ConditionGroup = conditionGroup
|
req.ConditionGroup = conditionGroup
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,7 @@ func (u *Update) Invoke(ctx context.Context, in map[string]any) (map[string]any,
|
||||||
Fields: fields,
|
Fields: fields,
|
||||||
IsDebugRun: isDebugExecute(ctx),
|
IsDebugRun: isDebugExecute(ctx),
|
||||||
UserID: getExecUserID(ctx),
|
UserID: getExecUserID(ctx),
|
||||||
|
ConnectorID: getConnectorID(ctx),
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := u.updater.Update(ctx, req)
|
response, err := u.updater.Update(ctx, req)
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ require (
|
||||||
github.com/aws/smithy-go v1.22.4 // indirect
|
github.com/aws/smithy-go v1.22.4 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/blang/semver/v4 v4.0.0 // indirect
|
github.com/blang/semver/v4 v4.0.0 // indirect
|
||||||
github.com/bytedance/gopkg v0.1.1 // indirect
|
github.com/bytedance/gopkg v0.1.1
|
||||||
github.com/bytedance/sonic/loader v0.2.4 // indirect
|
github.com/bytedance/sonic/loader v0.2.4 // indirect
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue