Commit Graph

66 Commits

Author SHA1 Message Date
Florian Bruhin 3eb826f664 reuse: Update remaining copyright texts
git ls-files | \
    xargs sed -Ei 's/Copyright [0-9]{4}(-[0-9]{4}) ([^<]*)<([^>]*)>/SPDX-FileCopyrightText: \2<\3>/'
2023-07-23 12:52:01 +02:00
Florian Bruhin b2aaba6043 reuse: Adjust most license headers
git ls-files | xargs grep -l "is free software"  | xargs reuse annotate --license="GPL-3.0-or-later" --skip-unrecognised
2023-07-23 12:11:07 +02:00
Philipp Albrecht d9e8b638bf Remove vim modelines
We're deprecating vim modelines in favor of `.editorconfig`.

Removing vim modelines could be done using two one-liners. Most of the vim modelines
were followed by an empty line, so this one-liner took care of these ones:

```sh
rg '^# vim: .+\n\n' -l | xargs sed -i '/^# vim: /,+1d'
```

Then some of the vim modelines were followed by a pylint configuration line, so running
this one-liner afterwards took care of that:

```sh
rg '^# vim:' -l | xargs sed -i '/^# vim: /d'
```
2023-06-30 11:03:06 +02:00
Florian Bruhin 4793070db3 Merge branch 'qt6-v2' into master-qt6 2023-03-17 20:30:13 +01:00
toofar ff8dbc4580 lint: broad-exception-raised
Mostly pretty lazy fixes. Most of the places in the tests we were
already matching on error message, a couple of places we weren't. The
tick-tock one was the only one that wasn't being used right where it was
raised.

Some of them I just changed to RuntimeError because it was shorter than
adding the pylint directive.
2023-02-06 18:53:56 +13:00
Florian Bruhin ee4d6e0396 sql: Add *all* primary sqlite result codes
For three reasons:

- There are only 31 of them, and we don't really expect any more to
  turn up (last happened in 2013, and we have a test for it happening)
- It makes for nicer debug output
- It always felt strange to only have a small subset in the enum
2022-08-26 19:11:15 +02:00
Florian Bruhin 6ffc5174ea sql: Handle sqlite extended error codes
Qt 6.1 switched to using extended sqlite error codes:
https://codereview.qt-project.org/c/qt/qtbase/+/329472

This is neat because it gives us more granularity for errors, but it
also means that we now need to account for that by masking the error
codes accordingly for checking their category.

See unhandled I/O error here:
https://crashes.qutebrowser.org/view/d9b26c2f
2022-08-26 19:08:49 +02:00
Florian Bruhin 0877fb0d78 Run scripts/dev/rewrite_enums.py 2022-08-23 18:31:38 +02:00
Florian Bruhin d47cfd99d7 Run scripts/dev/rewrite_qt_imports.sh 2022-08-23 18:09:11 +02:00
lufte 0c7b746a4e Restore the sql fixture to close DBs after testing 2021-07-09 01:10:36 -03:00
lufte 484ac43cf1 Fix function name too short 2021-07-03 01:00:32 -03:00
lufte 9949b4c5d6 No need to create new databases each time 2021-07-02 23:35:20 -03:00
lufte 082916b45d Add unit tests for the Transaction class 2021-07-02 23:25:59 -03:00
lufte 3b87db9059 Make version() a plain function 2021-06-30 01:13:54 -03:00
lufte 038d64b901 Update test_sql unit tests 2021-06-28 22:58:15 -03:00
Lembrun e8b05af233 Qtbot methods changed to snake case,snake case check added 2021-02-26 22:07:08 +01:00
Florian Bruhin 2b47bd01db Improve rebuilding of history database
- Re-add the force_rebuild key which we need internally again. This
partially reverts changes from:
  * cd0000f728
  * 1a9b59fcfa
  * 93ecd8f72f

- Instead of checking self.completion to figure out whether we need to
  rebuild anything, check 'self' (i.e. the History table, not the
  CompletionHistory table). If something went wrong during the last
  rebuild, the CompletionHistory might still be empty, but History is what
  actually matters to figure out whether to rebuild.

- Set force_rebuild while rebuilding the history, so that a possible
  interruption of the process (e.g. by a killed process or crash)
  results in another rebuild from scratch.

- Bump up the user version again, so that we re-add force_rebuild to the
  database. This also forces another rebuild which helps with possible
  inconsistent data when someone interrupted the earlier rebuild for
  v2.0.0.

Fixes #6111
2021-02-03 18:30:50 +01:00
Florian Bruhin 1a4fff1a42 doc: Switch URLs to https 2021-01-26 15:19:01 +01:00
Florian Bruhin 222f1f19a1 Bump copyright years
Closes #6015
2021-01-20 20:06:19 +01:00
Florian Bruhin fb5e105c19 sql: Remove .delete(like=True)
Mostly reverts bdab7b35b6 as we didn't end
up using it in b2fcc270ec.
2021-01-14 11:55:34 +01:00
Florian Bruhin 84ad7c990b sql: Improve/fix rows_affected() tests 2021-01-14 11:53:09 +01:00
Florian Bruhin 4d893e75a1 sql: Add Query.__bool__
Makes it clearer what the intent is (rather than implicitly falling back
on __len__ via Python) and also happens to be a small (most probably
insignificant) performance improvement.

On my machine, without a __bool__:

  Name (time in us)            Min       Max    Median
  test_bool_benchmark     144.2940  879.5960  167.2730

With it:

  Name (time in us)            Min       Max    Median
  test_bool_benchmark     133.3990  876.1080  152.1879
2021-01-14 11:24:31 +01:00
Florian Bruhin 0e4b807beb sql: Fix test 2021-01-14 10:58:06 +01:00
Florian Bruhin fcfa069a06 sql: Add major/minor user version infra
Not used at the moment, but allows for future changes.
2021-01-05 18:32:57 +01:00
Florian Bruhin bdab7b35b6 sql: Add .delete(..., like=True) 2021-01-05 18:32:57 +01:00
Florian Bruhin cd0000f728 history: Remove old force_rebuild values 2021-01-02 17:09:44 +01:00
Florian Bruhin ada468a8d7 old qt: Drop SQL error workaround 2020-11-04 18:30:04 +01:00
Florian Bruhin 9e4276db9b Adjust copyrights for 2020 2020-01-04 18:21:17 +01:00
Florian Bruhin 217cfb519e Remove Sql prefix for SqlKnownError and SqlBugError
We already have the sql module as namespace, no need to repeat it.
2019-04-03 10:34:37 +02:00
Florian Bruhin 03af6bb9b8 Finish environmental -> known rename 2019-04-03 10:31:24 +02:00
Jay Kamat 32802651da
Refactor LongQueryError and EnvironmentError into KnownError
- Also generalize catch on histcategory sql query to fix #4687
2019-04-02 21:35:32 -07:00
Jay Kamat 3e816f5f8b
Update copyright for 2019 2019-02-22 21:45:08 -08:00
Florian Bruhin 3b8964183e Use caplog.messages 2018-10-24 10:57:17 +02:00
Florian Bruhin 91b8002dd5 Clean up workaround for sqlite opening errors
Now that we know the real cause, we can be a bit stricter with our workaround.
2018-09-12 16:06:57 +02:00
Florian Bruhin c2a072f9fe Fix handling of sqlite out of memory errors
The "error_code == -1" check never passed, as error_code (confusingly) is a
string of a number.
2018-09-12 01:36:50 +02:00
Florian Bruhin 37396d68f3 Define names for sqlite error codes 2018-09-01 22:25:22 +02:00
Florian Bruhin f5c92ded41 Merge Sql{Environment,Bug}Error with Sqlite{Environment,Bug}Error 2018-09-01 22:25:22 +02:00
Florian Bruhin 50ae2bf2f9 Redesign SQL error handling
Instead of having an environmental attribute on exceptions, we now have two
different exception classes.

Fixes #3341
See #3073
2018-09-01 22:25:22 +02:00
Florian Bruhin 3f2a468750 Also detect missing bound values for sql.Query.run_batch 2018-09-01 18:25:58 +02:00
Florian Bruhin fa1fe63a93 Add some more sql.Query tests 2018-09-01 18:25:58 +02:00
Florian Bruhin 0e284944e7 Use composition instead of inheritance for sql.Query
This means we're more loosely coupled to Qt's QSqlQuery, and also can move some
logic for handling batch queries from the table to there.
2018-09-01 18:25:58 +02:00
Florian Bruhin 6b719fb218 Make sure queries don't have any missing bindings 2018-09-01 18:25:58 +02:00
Florian Bruhin 1d6282fd6c Add some tests for sql.Query 2018-09-01 18:25:58 +02:00
Florian Bruhin 6f028e9ad0 Update copyright years 2018-02-05 12:19:50 +01:00
Florian Bruhin e65c0dd8a7 pylint: Re-enable bad-continuation
And lots and lots of whitespace changes.
2017-12-15 19:16:55 +01:00
Florian Bruhin e76732693c Fix wrong import order 2017-12-15 14:35:07 +01:00
Florian Bruhin 96bec9f9d7 Fix error code for "database is locked"
See #2930
2017-10-17 15:35:23 +02:00
Florian Bruhin b5777299fd Fix getting a short text from the SqlError 2017-10-09 16:08:56 +02:00
Florian Bruhin b608259751 Handle some sqlite errors gracefully
We mark some SQL errors as "environmental", and then show those as error
messages instead of raising an exception.

Fixes #3004
Workaround for #2930
2017-10-09 16:06:24 +02:00
Florian Bruhin 5af8a95c82 Refactor SQL error handling
This renames SqlException to SqlError (to be more consistent with how Python
names exceptions), and adds an utility function which logs a few more useful
details about errors.

See #3004
2017-10-02 09:48:15 +02:00