Skip to content

Conversation

csunny
Copy link
Collaborator

@csunny csunny commented Mar 21, 2025

Description

When column has alias name, there will be error occur.

def _copy_public_properties(src: BaseModel, dest: BaseModel):
    """Copy public properties from src to dest."""
    for column in src.__table__.columns:  # type: ignore
        if column.name != "id":
            value = getattr(src, column.name)
            if value is not None:
                setattr(dest, column.name, value)

I fix this with follow code

def _copy_public_properties(src: BaseModel, dest: BaseModel):
    """Copy public properties from src to dest."""
    for column in inspect(src).mapper.column_attrs:
        if column.key != "id":
            alais = column.key
            value = getattr(src, alais)
            if value is not None:
                setattr(dest, column.key, value)

Checklist:

  • My code follows the style guidelines of this project
  • I have already rebased the commits and make the commit message conform to the project standard.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • Any dependent changes have been merged and published in downstream modules

@github-actions github-actions bot added the fix Bug fixes label Mar 21, 2025
Copy link
Collaborator

@fangyinc fangyinc left a comment

Choose a reason for hiding this comment

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

r+

Copy link
Collaborator

@yyhhyyyyyy yyhhyyyyyy left a comment

Choose a reason for hiding this comment

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

r+

@yyhhyyyyyy yyhhyyyyyy merged commit ca0d1ec into main Mar 21, 2025
2 checks passed
@fangyinc fangyinc deleted the fix-storage branch March 21, 2025 07:59
FOkvj pushed a commit to FOkvj/DB-GPT that referenced this pull request Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants