Browse Source

Fix sqlalchemy grouping on v1 storage

This fixes "CompileError: Can't resolve label reference for
ORDER BY / GROUP BY." error messages raised by sqlalchemy when the groupby
expression includes a comma.

Change-Id: Ia253175b45b8222aaee415ea535fa4102312be5a
(cherry picked from commit 5fef2d68f3)
tags/8.0.1^0
Luka Peschke 1 year ago
parent
commit
df869e4588
2 changed files with 7 additions and 1 deletions
  1. +1
    -1
      cloudkitty/storage/v1/sqlalchemy/__init__.py
  2. +6
    -0
      releasenotes/notes/fix-v1-storage-groupby-e865d1315bd390cb.yaml

+ 1
- 1
cloudkitty/storage/v1/sqlalchemy/__init__.py View File

@@ -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))


+ 6
- 0
releasenotes/notes/fix-v1-storage-groupby-e865d1315bd390cb.yaml View File

@@ -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.

Loading…
Cancel
Save