Skip to content

Commit

Permalink
Restore id column in History table
Browse files Browse the repository at this point in the history
The id attribute is used in the definition of the `update_time`
column_property.

Since id is inherited from a mixin, it is not available on the History class at mapping time.
The `remote_side` and `foreign_keys` parameters of the relationship
function face the same problem; however they can be defined as a
callable, which defers resolving the identifiers they contain, which
solves this problem. `column_property` does not accept a callable in
place of its argument, so the only way around is to define it after the
class has been defined - and we do so for several classes (see bottom of
the model/__init__ module. However, it appears to be impossible to use
this approach for the update_time attribute because it is also the name
of the database table column, which is defined inside the class
definition. Moving that column definition outside the class would add
unnecessary complexity: redefining the id column, I think, is the
reasonable approach here.
  • Loading branch information
jdavcs committed Jan 24, 2025
1 parent 8f40a12 commit 27b2097
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3127,6 +3127,7 @@ class History(Base, HasTags, Dictifiable, UsesAnnotations, HasName, Serializable
__tablename__ = "history"
__table_args__ = (Index("ix_history_slug", "slug", mysql_length=200),)

id: Mapped[int] = mapped_column(primary_key=True) # duplicated intentionally due to update_time column_property
create_time: Mapped[datetime] = mapped_column(default=now, nullable=True)
_update_time: Mapped[datetime] = mapped_column(
"update_time", DateTime, index=True, default=now, onupdate=now, nullable=True
Expand Down

0 comments on commit 27b2097

Please sign in to comment.