From fa4fbcf5b584a0bb1c1f9df2fa1adb455669d428 Mon Sep 17 00:00:00 2001 From: AKamyshnikova Date: Tue, 6 Oct 2015 11:23:11 +0300 Subject: [PATCH] Add note in database section of 'effective neutron' Add note about usage aggregate functions with GROUP BY for PostgreSQL. Change-Id: I50af8e8e19f638f774d0f1cfb30f56f6cecad65e --- doc/source/devref/effective_neutron.rst | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/source/devref/effective_neutron.rst b/doc/source/devref/effective_neutron.rst index 4cbea6e6f..bdca1e3ce 100644 --- a/doc/source/devref/effective_neutron.rst +++ b/doc/source/devref/effective_neutron.rst @@ -63,7 +63,22 @@ Document common pitfalls as well as good practices done during database developm does not raise an exception. * Do not get an object to delete it. If you can `delete() `_ on the query object. Read the warnings for more details about in-python cascades. -* ... +* For PostgreSQL if you're using GROUP BY everything in the SELECT list must be + an aggregate SUM(...), COUNT(...), etc or used in the GROUP BY. + + The incorrect variant: + + .. code:: python + + q = query(Object.id, Object.name, + func.count(Object.number)).group_by(Object.name) + + The correct variant: + + .. code:: python + + q = query(Object.id, Object.name, + func.count(Object.number)).group_by(Object.id, Object.name) System development ~~~~~~~~~~~~~~~~~~ -- 2.45.2