MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / visit_function

Method visit_function

lib/sqlalchemy/sql/compiler.py:2974–3018  ·  view source on GitHub ↗
(
        self,
        func: Function[Any],
        add_to_result_map: Optional[_ResultMapAppender] = None,
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

2972 return "(%s).%s" % (compiled_fn, compiled_col)
2973
2974 def visit_function(
2975 self,
2976 func: Function[Any],
2977 add_to_result_map: Optional[_ResultMapAppender] = None,
2978 **kwargs: Any,
2979 ) -> str:
2980 if add_to_result_map is not None:
2981 add_to_result_map(func.name, func.name, (func.name,), func.type)
2982
2983 disp = getattr(self, "visit_%s_func" % func.name.lower(), None)
2984
2985 text: str
2986
2987 if disp:
2988 text = disp(func, **kwargs)
2989 else:
2990 name = FUNCTIONS.get(func._deannotate().__class__, None)
2991 if name:
2992 if func._has_args:
2993 name += "%(expr)s"
2994 else:
2995 name = func.name
2996 name = (
2997 self.preparer.quote(name)
2998 if self.preparer._requires_quotes_illegal_chars(name)
2999 or isinstance(name, elements.quoted_name)
3000 else name
3001 )
3002 name = name + "%(expr)s"
3003 text = ".".join(
3004 [
3005 (
3006 self.preparer.quote(tok)
3007 if self.preparer._requires_quotes_illegal_chars(tok)
3008 or isinstance(name, elements.quoted_name)
3009 else tok
3010 )
3011 for tok in func.packagenames
3012 ]
3013 + [name]
3014 ) % {"expr": self.function_argspec(func, **kwargs)}
3015
3016 if func._with_ordinality:
3017 text += " WITH ORDINALITY"
3018 return text
3019
3020 def visit_next_value_func(self, next_value, **kw):
3021 return self.visit_sequence(next_value.sequence)

Callers 2

default_greatestMethod · 0.45

Calls 7

function_argspecMethod · 0.95
lowerMethod · 0.80
getMethod · 0.45
_deannotateMethod · 0.45
quoteMethod · 0.45
joinMethod · 0.45

Tested by 1

default_greatestMethod · 0.36