From: AKamyshnikova Date: Tue, 6 Oct 2015 08:23:11 +0000 (+0300) Subject: Add note in database section of 'effective neutron' X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=fa4fbcf5b584a0bb1c1f9df2fa1adb455669d428;p=openstack-build%2Fneutron-build.git Add note in database section of 'effective neutron' Add note about usage aggregate functions with GROUP BY for PostgreSQL. Change-Id: I50af8e8e19f638f774d0f1cfb30f56f6cecad65e --- 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 ~~~~~~~~~~~~~~~~~~