Skip to content

Commit

Permalink
Merge pull request #1393 from Callum027/metric-resource-relationship-fix
Browse files Browse the repository at this point in the history
Switch Metric-Resource relationship to back_populates
  • Loading branch information
tobias-urdin authored Aug 16, 2024
2 parents b08df42 + 287092d commit 3e84ca5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions gnocchi/indexer/sqlalchemy_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ class Metric(Base, GnocchiBase, indexer.Metric):
sqlalchemy.ForeignKey('resource.id',
ondelete="SET NULL",
name="fk_metric_resource_id_resource_id"))

resource = sqlalchemy.orm.relationship("Resource",
back_populates="metrics")
name = sqlalchemy.Column(sqlalchemy.String(255))
unit = sqlalchemy.Column(sqlalchemy.String(31))
status = sqlalchemy.Column(sqlalchemy.Enum('active', 'delete',
Expand Down Expand Up @@ -273,7 +274,7 @@ class Resource(ResourceMixin, Base, GnocchiBase):
primary_key=True)
revision_end = None
metrics = sqlalchemy.orm.relationship(
Metric, backref="resource",
Metric, back_populates="resource",
primaryjoin="and_(Resource.id == Metric.resource_id, "
"Metric.status == 'active')")

Expand Down

0 comments on commit 3e84ca5

Please sign in to comment.