MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / visit_over

Method visit_over

lib/sqlalchemy/sql/compiler.py:2996–3026  ·  view source on GitHub ↗
(self, over, **kwargs)

Source from the content-addressed store, hash-verified

2994 return f"{left} AND {right}"
2995
2996 def visit_over(self, over, **kwargs):
2997 text = over.element._compiler_dispatch(self, **kwargs)
2998 if over.range_ is not None:
2999 range_ = f"RANGE BETWEEN {self.process(over.range_, **kwargs)}"
3000 elif over.rows is not None:
3001 range_ = f"ROWS BETWEEN {self.process(over.rows, **kwargs)}"
3002 elif over.groups is not None:
3003 range_ = f"GROUPS BETWEEN {self.process(over.groups, **kwargs)}"
3004 else:
3005 range_ = None
3006
3007 if range_ is not None and over.exclude is not None:
3008 range_ += " EXCLUDE " + self.preparer.validate_sql_phrase(
3009 over.exclude, _WINDOW_EXCLUDE_RE
3010 )
3011
3012 return "%s OVER (%s)" % (
3013 text,
3014 " ".join(
3015 [
3016 "%s BY %s"
3017 % (word, clause._compiler_dispatch(self, **kwargs))
3018 for word, clause in (
3019 ("PARTITION", over.partition_by),
3020 ("ORDER", over.order_by),
3021 )
3022 if clause is not None and len(clause)
3023 ]
3024 + ([range_] if range_ else [])
3025 ),
3026 )
3027
3028 def visit_withingroup(self, withingroup, **kwargs):
3029 return "%s WITHIN GROUP (ORDER BY %s)" % (

Callers

nothing calls this directly

Calls 4

validate_sql_phraseMethod · 0.80
_compiler_dispatchMethod · 0.45
processMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected