Skip to content

[Bug][Pydevlake] Misalignement of Models between Go and Python - missing Primary Keys in PullRequestLabels #8954

Description

@dg-nvm

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

Go code defines PrimaryKeys like that:

type PullRequestLabel struct {
	PullRequestId string `json:"id" gorm:"primaryKey;type:varchar(255);comment:This key is generated based on details from the original plugin"` // format: <Plugin>:<Entity>:<PK0>:<PK1>
	LabelName     string `gorm:"primaryKey;type:varchar(255)"`
	common.NoPKModel
}

and Python:

class PullRequestLabels(NoPKModel, table=True):
    __tablename__ = 'pull_request_labels'
    pull_request_id: str = Field(primary_key=True)
    label_name: str

What do you expect to happen

they should align

How to reproduce

nothing to repro - this is problem in the code itself

Anything else

workaround is to use extend_existing to internally in the code expand definition:

class PullRequestLabels(NoPKModel, table=True):
    """
    Domain model for pull_request_labels table with the correct composite PK.

    Patches the vendored pydevlake.domain_layer.code.PullRequestLabels to use
    a composite primary key (pull_request_id, label_name) matching the Go
    DevLake domain layer definition.
    """

    __tablename__ = "pull_request_labels"
    __table_args__ = {"extend_existing": True}

    pull_request_id: str = Field(primary_key=True)
    label_name: str = Field(primary_key=True)

Version

f2de2dc

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugThis issue is a bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions