From ea10fb239f5731f4ff365a21d778485b88ee3f20 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Tue, 9 Mar 2021 10:48:47 -0500 Subject: [PATCH] query: Add a user hint for query TypeErrors. The error message that native bean-query provides when this happens confuses many users. Add a hint to point them in the right direction. --- conservancy_beancount/reports/query.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/conservancy_beancount/reports/query.py b/conservancy_beancount/reports/query.py index 08a700a..69822b9 100644 --- a/conservancy_beancount/reports/query.py +++ b/conservancy_beancount/reports/query.py @@ -238,6 +238,15 @@ 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.", + ) return if not rows and output_format != 'ods':