MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / order_by_clause

Method order_by_clause

lib/sqlalchemy/dialects/mssql/base.py:2412–2435  ·  view source on GitHub ↗
(self, select, **kw)

Source from the content-addressed store, hash-verified

2410 return ""
2411
2412 def order_by_clause(self, select, **kw):
2413 # MSSQL only allows ORDER BY in subqueries if there is a LIMIT:
2414 # "The ORDER BY clause is invalid in views, inline functions,
2415 # derived tables, subqueries, and common table expressions,
2416 # unless TOP, OFFSET or FOR XML is also specified."
2417 if (
2418 self.is_subquery()
2419 and not self._use_top(select)
2420 and (
2421 select._offset is None
2422 or not self.dialect._supports_offset_fetch
2423 )
2424 ):
2425 # avoid processing the order by clause if we won't end up
2426 # using it, because we don't want all the bind params tacked
2427 # onto the positional list if that is what the dbapi requires
2428 return ""
2429
2430 order_by = self.process(select._order_by_clause, **kw)
2431
2432 if order_by:
2433 return " ORDER BY " + order_by
2434 else:
2435 return ""
2436
2437 def update_from_clause(
2438 self, update_stmt, from_table, extra_froms, from_hints, **kw

Callers

nothing calls this directly

Calls 3

_use_topMethod · 0.95
is_subqueryMethod · 0.80
processMethod · 0.45

Tested by

no test coverage detected