MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / register_function

Function register_function

lib/sqlalchemy/sql/functions.py:95–116  ·  view source on GitHub ↗

Associate a callable with a particular func. name. This is normally called by GenericFunction, but is also available by itself so that a non-Function construct can be associated with the :data:`.func` accessor (i.e. CAST, EXTRACT).

(
    identifier: str, fn: Type[Function[Any]], package: str = "_default"
)

Source from the content-addressed store, hash-verified

93
94
95def register_function(
96 identifier: str, fn: Type[Function[Any]], package: str = "_default"
97) -> None:
98 """Associate a callable with a particular func. name.
99
100 This is normally called by GenericFunction, but is also
101 available by itself so that a non-Function construct
102 can be associated with the :data:`.func` accessor (i.e.
103 CAST, EXTRACT).
104
105 """
106 reg = _registry[package]
107
108 identifier = str(identifier).lower()
109
110 # Check if a function with the same identifier is registered.
111 if identifier in reg:
112 util.warn(
113 "The GenericFunction '{}' is already registered and "
114 "is going to be overridden.".format(identifier)
115 )
116 reg[identifier] = fn
117
118
119class FunctionElement(

Callers 2

functions.pyFile · 0.85

Calls 2

lowerMethod · 0.80
warnMethod · 0.45

Tested by

no test coverage detected