Use more intuitive argument order in sql.delete.
This commit is contained in:
parent
9c0c174534
commit
c007f592b3
@ -122,8 +122,8 @@ class WebHistory(sql.SqlTable):
|
||||
Args:
|
||||
url: URL string to delete.
|
||||
"""
|
||||
self.delete(url, 'url')
|
||||
self.completion.delete(url, 'url')
|
||||
self.delete('url', url)
|
||||
self.completion.delete('url', url)
|
||||
|
||||
@pyqtSlot(QUrl, QUrl, str)
|
||||
def add_from_tab(self, url, requested_url, title):
|
||||
|
@ -78,7 +78,6 @@ class SqlCategory(QSqlQueryModel):
|
||||
|
||||
Args:
|
||||
pattern: string pattern to filter by.
|
||||
columns_to_filter: indices of columns to apply pattern to.
|
||||
"""
|
||||
# escape to treat a user input % or _ as a literal, not a wildcard
|
||||
pattern = pattern.replace('%', '\\%')
|
||||
|
@ -170,12 +170,12 @@ class SqlTable(QObject):
|
||||
q.run()
|
||||
return q.value()
|
||||
|
||||
def delete(self, value, field):
|
||||
def delete(self, field, value):
|
||||
"""Remove all rows for which `field` equals `value`.
|
||||
|
||||
Args:
|
||||
value: Key value to delete.
|
||||
field: Field to use as the key.
|
||||
value: Key value to delete.
|
||||
|
||||
Return:
|
||||
The number of rows deleted.
|
||||
|
@ -124,12 +124,12 @@ def test_delete(qtbot):
|
||||
table.insert({'name': 'nine', 'val': 9, 'lucky': False})
|
||||
table.insert({'name': 'thirteen', 'val': 13, 'lucky': True})
|
||||
with pytest.raises(KeyError):
|
||||
table.delete('nope', 'name')
|
||||
table.delete('name', 'nope')
|
||||
with qtbot.waitSignal(table.changed):
|
||||
table.delete('thirteen', 'name')
|
||||
table.delete('name', 'thirteen')
|
||||
assert list(table) == [('one', 1, False), ('nine', 9, False)]
|
||||
with qtbot.waitSignal(table.changed):
|
||||
table.delete(False, field='lucky')
|
||||
table.delete('lucky', False)
|
||||
assert not list(table)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user