Skip to content

Commit

Permalink
Fix version file warnings
Browse files Browse the repository at this point in the history
RemovedIn20Warning: "Version" object is being merged into a Session along the backref cascade path for relationship "Bundle.versions"; in SQLAlchemy 2.0, this reverse cascade will not take place.  Set cascade_backrefs to False in either the relationship() or backref() function for the 2.0 behavior; or to set globally for the whole Session, set the future=True flag (Background on this error at: https://sqlalche.me/e/14/s9r1) (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
    version_obj.bundle = bundle
  • Loading branch information
seallard committed Oct 11, 2023
1 parent 9269d73 commit 725ad7c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions housekeeper/store/api/handlers/create.py
Expand Up @@ -73,6 +73,7 @@ def _add_files_to_version(self, files: List[dict], version_obj: Version) -> None
tags = [tag_map[tag_name] for tag_name in file_data["tags"]]
new_file = self.new_file(path, to_archive=file_data["archive"], tags=tags)
version_obj.files.append(new_file)
new_file.version_id = version_obj.id

def new_version(self, created_at: dt.datetime, expires_at: dt.datetime = None) -> Version:
"""Create a new bundle version."""
Expand Down
4 changes: 3 additions & 1 deletion housekeeper/store/models.py
Expand Up @@ -63,7 +63,9 @@ class Version(Model):
archive_checksum = Column(types.String(256), unique=True)

bundle_id = Column(ForeignKey(Bundle.id, ondelete="CASCADE"), nullable=False)
files = orm.relationship("File", backref="version", cascade="delete, save-update")
files = orm.relationship(
"File", backref=backref("version", cascade_backrefs=False), cascade="delete, save-update"
)

app_root = None

Expand Down

0 comments on commit 725ad7c

Please sign in to comment.