summaryrefslogtreecommitdiff
path: root/qutebrowser/completion/models/histcategory.py
diff options
context:
space:
mode:
Diffstat (limited to 'qutebrowser/completion/models/histcategory.py')
-rw-r--r--qutebrowser/completion/models/histcategory.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/qutebrowser/completion/models/histcategory.py b/qutebrowser/completion/models/histcategory.py
index 8b1be213a..175b458fd 100644
--- a/qutebrowser/completion/models/histcategory.py
+++ b/qutebrowser/completion/models/histcategory.py
@@ -22,7 +22,7 @@
from PyQt5.QtSql import QSqlQueryModel
from qutebrowser.misc import sql
-from qutebrowser.utils import debug
+from qutebrowser.utils import debug, message
from qutebrowser.config import config
@@ -88,15 +88,21 @@ class HistoryCategory(QSqlQueryModel):
if not self._query or len(words) != len(self._query.bound_values()):
# if the number of words changed, we need to generate a new query
# otherwise, we can reuse the prepared query for performance
- self._query = sql.Query(' '.join([
- "SELECT url, title, {}".format(timefmt),
- "FROM CompletionHistory",
- # the incoming pattern will have literal % and _ escaped
- # we need to tell sql to treat '\' as an escape character
- 'WHERE ({})'.format(where_clause),
- self._atime_expr(),
- "ORDER BY last_atime DESC",
- ]), forward_only=False)
+ try:
+ self._query = sql.Query(' '.join([
+ "SELECT url, title, {}".format(timefmt),
+ "FROM CompletionHistory",
+ # the incoming pattern will have literal % and _ escaped
+ # we need to tell sql to treat '\' as an escape character
+ 'WHERE ({})'.format(where_clause),
+ self._atime_expr(),
+ "ORDER BY last_atime DESC",
+ ]), forward_only=False)
+ except sql.SqlLongQueryError as e:
+ # Sometimes, the query we built up was invalid, for example,
+ # due to a large amount of words.
+ message.error("Error building SQL Query: {}".format(e.text()))
+ return
with debug.log_time('sql', 'Running completion query'):
self._query.run(**{