Replace previously registered convert functions with the same name

This commit is contained in:
Zihan Dai 2026-10-20 15:42:30 +11:00
commit cab088f765
2 changed files with 23 additions and 1 deletions

View file

@ -4235,7 +4235,10 @@ class Table(Queryable):
fn_name = getattr(fn, "__name__", "fn")
if fn_name == "<lambda>":
fn_name = f"lambda_{abs(hash(fn))}"
self.db.register_function(convert_value, name=fn_name)
# replace=True: a previous .convert() may have registered a
# different callable under the same name, e.g. two bound methods
# called "get" or two functools.partial objects
self.db.register_function(convert_value, name=fn_name, replace=True)
sql = "update {} set {sets}{where};".format(
quote_identifier(self.name),
sets=", ".join(