Skip to content

has_many_association bug #470

@walijoy

Description

@walijoy

debug

runtime/debug.Stack(0x502c9dd, 0x2, 0xc000318838)
        /usr/local/Cellar/go/1.13.4/libexec/src/runtime/debug/stack.go:24 +0x9d
git.liebaopay.com/INA_financial/rpc_services/app/srv/workflow/services.(*Workflow).CreateNode.func1(0xc0002e12c0)
        /app/go/rpc_services/app/srv/workflow/services/node.go:30 +0xde
panic(0x4e53060, 0xc000400120)
        /usr/local/Cellar/go/1.13.4/libexec/src/runtime/panic.go:679 +0x1b2
reflect.valueInterface(0x0, 0x0, 0x0, 0x502ca01, 0x2, 0x0)
        /usr/local/Cellar/go/1.13.4/libexec/src/reflect/value.go:1008 +0x1a0
reflect.Value.Interface(...)
        /usr/local/Cellar/go/1.13.4/libexec/src/reflect/value.go:1003
github.com/gobuffalo/pop/associations.(*hasManyAssociation).AfterProcess(0xc0001460f0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /Users/chenjiang/go/pkg/mod/github.com/gobuffalo/pop@v4.12.2+incompatible/associations/has_many_association.go:133 +0x16c
github.com/gobuffalo/pop.(*Connection).Create.func1.1(0xbf6f0b7565401648, 0x1fecb0180)
        /Users/chenjiang/go/pkg/mod/github.com/gobuffalo/pop@v4.12.2+incompatible/executors.go:273 +0x36d

incompatible/associations/has_many_association.go:133 +0x16c

func (a *hasManyAssociation) AfterProcess() AssociationStatement {
	v := a.value
	if v.Kind() == reflect.Ptr {
		v = v.Elem()
	}

	belongingIDFieldName := "ID"

	ownerIDFieldName := "ID"
	ownerID := 
       reflect.Indirect(reflect.ValueOf(a.owner)).FieldByName(ownerIDFieldName).Interface()  <--

model

type WorkflowNode struct {
	Id         int64          `json:"id" db:"id"`   <----- not ID
	WorkflowId int64          `json:"workflow_id" db:"workflow_id"`
	Name       string         `json:"name" db:"name"`
	Reviewers  types.JSONText `json:"reviewers" db:"reviewers" `
	Data       string         `json:"data" db:"data" `
	Rules      types.JSONText `json:"rules" db:"rules" `
	CreatedAt  int64          `json:"created_at" db:"created_at"`
	UpdatedAt  int64          `json:"updated_at" db:"updated_at"`

        //This line of code causes bug
	FromNodeEdges []WorkflowEdges `has_many:"workflow_graphs" primary_key:"id" fk_id:"from_node_id"`
}

run

	node := models.WorkflowNode{
		Name:       in.Name,
		WorkflowId: in.WorkflowId,
		Data:       in.Data,
		Reviewers:  types.JSONText(string(reviewersJsonByte)),
		Rules:      types.JSONText(in.Rules),
	}

	err = p.Def().Create(&node)
	if err != nil {
		out.Code = proto.Code_fail
		out.Message = MessageSystemException
		return nil
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: associationsthe associations feature in pops: triageSome tests need to be run to confirm the issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions