diff --git a/conservancy_beancount/reports/query.py b/conservancy_beancount/reports/query.py index 9ea5052789f85e1022d7d3e2e0e87c14c10dbb7c..75749d8923a38dd235100ae0855d942c7fab5244 100644 --- a/conservancy_beancount/reports/query.py +++ b/conservancy_beancount/reports/query.py @@ -556,15 +556,12 @@ class BQLShell(bc_query_shell.BQLShell): ) except Exception as error: logger.error(str(error), exc_info=logger.isEnabledFor(logging.DEBUG)) - if (isinstance(error, TypeError) - and error.args - and ' not supported between instances ' in error.args[0]): - logger.info( - "HINT: Are you using ORDER BY or comparisons with metadata " - "that isn't consistently set?\n " - "Try looking up that metadata with str_meta() instead to " - "ensure your comparisons use a consistent data type.", - ) + try: + hint_func = getattr(self, f'_hint_{type(error).__name__}') + except AttributeError: + pass + else: + hint_func(error, statement) return if not rows and output_format != 'ods': @@ -573,6 +570,26 @@ class BQLShell(bc_query_shell.BQLShell): logger.debug("rendering query as %s", output_format) render_func(statement, row_types, rows) + def _hint_TypeError(self, error: TypeError, statement: QueryStatement) -> None: + try: + errmsg = str(error.args[0]) + except IndexError: + return + if ' not supported between instances ' in errmsg: + logger.info( + "HINT: Are you using ORDER BY or comparisons with metadata " + "that isn't consistently set?\n " + "Try looking up that metadata with str_meta() instead to " + "ensure your comparisons use a consistent data type.", + ) + elif errmsg.startswith('unhashable type: '): + logger.info( + "HINT: bean-query does not support selecting columns or " + "functions that return multiple items as non-aggregate data in " + "GROUP BY queries.\n " + "If you want to aggregate that data, run it through set().", + ) + def _render_csv(self, statement: QueryStatement, row_types: RowTypes, rows: Rows) -> None: bc_query_render.render_csv( row_types, diff --git a/setup.py b/setup.py index d55c9be2663faa8f1b749e6a00b5e8776e8d75df..5e0f4bf9143d03bc28bf51dd35ff6fd2dd654137 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup setup( name='conservancy_beancount', description="Plugin, library, and reports for reading Conservancy's books", - version='1.19.3', + version='1.19.4', author='Software Freedom Conservancy', author_email='info@sfconservancy.org', license='GNU AGPLv3+',