mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-27 04:14:30 +02:00
Fixed bug I introduced with register_function()
This commit is contained in:
parent
2da7af10a4
commit
cf92a29c2e
1 changed files with 7 additions and 1 deletions
|
|
@ -264,7 +264,7 @@ class Database:
|
||||||
return "<Database {}>".format(self.conn)
|
return "<Database {}>".format(self.conn)
|
||||||
|
|
||||||
def register_function(
|
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
|
``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):
|
def upper(value):
|
||||||
return str(value).upper()
|
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
|
- ``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
|
- ``replace`` - set ``True`` to replace an existing function with the same name - otherwise throw an error
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue