Skip to content
Please note that GitHub no longer supports Internet Explorer.

We recommend upgrading to the latest Microsoft Edge, Google Chrome, or Firefox.

Learn more
Permalink
Browse files

Handle yet another "too complex" sqlite error

  • Loading branch information
The-Compiler committed Jan 5, 2020
1 parent ee4f1c4 commit 73e2dd73573738bfea829c7685a4a4dda6bd6a57
Showing with 20 additions and 4 deletions.
  1. +2 −0 doc/changelog.asciidoc
  2. +2 −2 qutebrowser/misc/sql.py
  3. +16 −2 tests/unit/completion/test_histcategory.py
@@ -109,6 +109,8 @@ Fixed
- The tab hover text now shows ampersands (&) correctly.
- With QtWebEngine and Qt >= 5.11, the inspector now shows its icons correctly
even if loading of images is disabled via the `content.images` setting.
- Crash when entering a very long string (over 50k characters) in the
completion.
- Various improvements for URL/searchengine detection:
- Strings with a dot but with characters not allowed in a URL (e.g. an
underscore) are now not treated as URL anymore.
@@ -119,9 +119,9 @@ def raise_sqlite_error(msg, error):
# If the query we built was too long
too_long_err = (
error_code == SqliteErrorCode.ERROR and
driver_text == "Unable to execute statement" and
(database_text.startswith("Expression tree is too large") or
database_text == "too many SQL variables"))
database_text in ["too many SQL variables",
"LIKE or GLOB pattern too complex"]))

if error_code in known_errors or qtbug_70506 or too_long_err:
raise KnownError(msg, error)
@@ -22,6 +22,8 @@
import datetime
import logging

import hypothesis
from hypothesis import strategies
import pytest

from qutebrowser.misc import sql
@@ -135,15 +137,27 @@ def test_set_pattern_repeated(model_validator, hist):
])


def test_set_pattern_long(hist, message_mock, caplog):
@pytest.mark.parametrize('pattern', [
' '.join(map(str, range(10000))),
'x' * 50000,
], ids=['numbers', 'characters'])
def test_set_pattern_long(hist, message_mock, caplog, pattern):
hist.insert({'url': 'example.com/foo', 'title': 'title1', 'last_atime': 1})
cat = histcategory.HistoryCategory()
with caplog.at_level(logging.ERROR):
cat.set_pattern(" ".join(map(str, range(10000))))
cat.set_pattern(pattern)
msg = message_mock.getmsg(usertypes.MessageLevel.error)
assert msg.text.startswith("Error with SQL query:")


@hypothesis.given(pat=strategies.text())
def test_set_pattern_hypothesis(hist, pat, caplog):
hist.insert({'url': 'example.com/foo', 'title': 'title1', 'last_atime': 1})
cat = histcategory.HistoryCategory()
with caplog.at_level(logging.ERROR):
cat.set_pattern(pat)


@pytest.mark.parametrize('max_items, before, after', [
(-1, [
('a', 'a', '2017-04-16'),

0 comments on commit 73e2dd7

Please sign in to comment.
You can’t perform that action at this time.