]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Add note in database section of 'effective neutron'
authorAKamyshnikova <akamyshnikova@mirantis.com>
Tue, 6 Oct 2015 08:23:11 +0000 (11:23 +0300)
committerAKamyshnikova <akamyshnikova@mirantis.com>
Tue, 6 Oct 2015 08:23:11 +0000 (11:23 +0300)
Add note about usage aggregate functions with GROUP BY for
PostgreSQL.

Change-Id: I50af8e8e19f638f774d0f1cfb30f56f6cecad65e

doc/source/devref/effective_neutron.rst

index 4cbea6e6febb78e395657eafa3f8edaa7433e4c5..bdca1e3cedad382994e288cebe4c459113fd689b 100644 (file)
@@ -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() <http://docs.sqlalchemy.org/en/rel_1_0/orm/query.html#sqlalchemy.orm.query.Query.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
 ~~~~~~~~~~~~~~~~~~