Support repeated calls to Table.convert()

* Test repeated calls to Table.convert()
* Register Table.convert() functions under their own `lambda_hash` name
* Raise exception on registering identical function names

Refs #525
This commit is contained in:
Martin Carpenter 2023-05-08 23:53:58 +02:00 committed by GitHub
commit 02f5c4d69d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 9 deletions

View file

@ -147,3 +147,12 @@ def test_convert_multi_exception(fresh_db):
table.insert({"title": "Mixed Case"})
with pytest.raises(BadMultiValues):
table.convert("title", lambda v: v.upper(), multi=True)
def test_convert_repeated(fresh_db):
table = fresh_db["table"]
col = "num"
table.insert({col: 1})
table.convert(col, lambda x: x*2)
table.convert(col, lambda _x: 0)
assert table.get(1) == {col: 0}