diff --git a/cloudkitty/storage/v1/sqlalchemy/__init__.py b/cloudkitty/storage/v1/sqlalchemy/__init__.py index 77403e34..7b56da68 100644 --- a/cloudkitty/storage/v1/sqlalchemy/__init__.py +++ b/cloudkitty/storage/v1/sqlalchemy/__init__.py @@ -127,7 +127,7 @@ class SQLAlchemyStorage(storage.BaseStorage): self.frame_model.end <= end, self.frame_model.res_type != '_NO_DATA_') if groupby: - q = q.group_by(groupby) + q = q.group_by(sqlalchemy.sql.text(groupby)) # Order by sum(rate) q = q.order_by(sqlalchemy.func.sum(self.frame_model.rate)) diff --git a/releasenotes/notes/fix-v1-storage-groupby-e865d1315bd390cb.yaml b/releasenotes/notes/fix-v1-storage-groupby-e865d1315bd390cb.yaml new file mode 100644 index 00000000..02c1e4dd --- /dev/null +++ b/releasenotes/notes/fix-v1-storage-groupby-e865d1315bd390cb.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + ``CompileError: Can't resolve label reference for ORDER BY / GROUP BY.`` + errors that were sometimes raised by SQLAlchemy when using the v1 storage + backend and grouping on ``tenant_id`` and ``res_type`` have been fixed.