Error in websupport get_metadata

Brad Miller avatarBrad Miller created an issue

Using postgres as storage backend. Using version 1.1.2

I get the following error when I call get_document

Traceback (most recent call last):
  File "/Users/bmiller/src/eds/gluon/", line 204, in restricted
    exec ccode in environment
  File "/Users/bmiller/src/eds/applications/eds/controllers/", line 32, in <module>
  File "/Users/bmiller/src/eds/gluon/", line 172, in <lambda>
    self._caller = lambda f: f()
  File "/Users/bmiller/src/eds/gluon/", line 2533, in f
    return action(*a, **b)
  File "/Users/bmiller/src/eds/applications/eds/controllers/", line 13, in chapter
    contents = web_support.get_document(doc)
  File "/Library/Python/2.7/site-packages/Sphinx-1.1.2-py2.7.egg/sphinx/websupport/", line 199, in get_document, moderator))
  File "/Library/Python/2.7/site-packages/Sphinx-1.1.2-py2.7.egg/sphinx/websupport/storage/", line 127, in get_metadata
    return dict([(k, v or 0) for k, v in nodes])
  File "build/bdist.macosx-10.7-intel/egg/sqlalchemy/orm/", line 2057, in __iter__
    return self._execute_and_instances(context)
  File "build/bdist.macosx-10.7-intel/egg/sqlalchemy/orm/", line 2072, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "build/bdist.macosx-10.7-intel/egg/sqlalchemy/engine/", line 1405, in execute
  File "build/bdist.macosx-10.7-intel/egg/sqlalchemy/engine/", line 1538, in _execute_clauseelement
    compiled_sql, distilled_params
  File "build/bdist.macosx-10.7-intel/egg/sqlalchemy/engine/", line 1646, in _execute_context
  File "build/bdist.macosx-10.7-intel/egg/sqlalchemy/engine/", line 1639, in _execute_context
  File "build/bdist.macosx-10.7-intel/egg/sqlalchemy/engine/", line 330, in do_execute
    cursor.execute(statement, parameters)
ProgrammingError: (ProgrammingError) column "" must appear in the GROUP BY clause or be used in an aggregate function
 'SELECT AS sphinx_nodes_id, anon_1.comment_count AS anon_1_comment_count \nFROM sphinx_nodes LEFT OUTER JOIN (SELECT AS id, sphinx_comments.node_id AS node_id, count(%(param_1)s) AS comment_count \nFROM sphinx_comments GROUP BY sphinx_comments.node_id) AS anon_1 ON = anon_1.node_id \nWHERE sphinx_nodes.document = %(document_1)s' {'document_1': 'analysis', 'param_1': '*'}

Note that this error does not occur when storage is set to sqlite

Comments (3)

  1. Brad Miller

    This fixes it, and runs for sqlite and postgresql:

    diff --git a/sphinx/websupport/storage/ b/sphinx/websupport/storage/
    --- a/sphinx/websupport/storage/
    +++ b/sphinx/websupport/storage/
    @@ -116,7 +116,7 @@
         def get_metadata(self, docname, moderator):
             session = Session()
             subquery = session.query(
    -  , Comment.node_id,
    +            Comment.node_id,
             nodes = session.query(, subquery.c.comment_count).outerjoin(
  2. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.