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