Fixed bug I introduced with register_function()

This commit is contained in:
Simon Willison 2021-08-10 10:08:23 -07:00
commit cf92a29c2e

View file

@ -264,7 +264,7 @@ class Database:
return "<Database {}>".format(self.conn)
def register_function(
self, fn: Callable, deterministic: bool = False, replace: bool = False
self, fn: Callable=None, deterministic: bool = False, replace: bool = False
):
"""
``fn`` will be made available as a function within SQL, with the same name and number
@ -274,6 +274,12 @@ class Database:
def upper(value):
return str(value).upper()
The decorator can take arguments::
@db.register(deterministic=True, replace=True)
def upper(value):
return str(value).upper()
- ``deterministic`` - set ``True`` for functions that always returns the same output for a given input
- ``replace`` - set ``True`` to replace an existing function with the same name - otherwise throw an error
"""