MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / fetch_clause

Method fetch_clause

lib/sqlalchemy/sql/compiler.py:5513–5552  ·  view source on GitHub ↗
(
        self,
        select,
        fetch_clause=None,
        require_offset=False,
        use_literal_execute_for_simple_int=False,
        **kw,
    )

Source from the content-addressed store, hash-verified

5511 return text
5512
5513 def fetch_clause(
5514 self,
5515 select,
5516 fetch_clause=None,
5517 require_offset=False,
5518 use_literal_execute_for_simple_int=False,
5519 **kw,
5520 ):
5521 if fetch_clause is None:
5522 fetch_clause = select._fetch_clause
5523 fetch_clause_options = select._fetch_clause_options
5524 else:
5525 fetch_clause_options = {"percent": False, "with_ties": False}
5526
5527 text = ""
5528
5529 if select._offset_clause is not None:
5530 offset_clause = select._offset_clause
5531 if (
5532 use_literal_execute_for_simple_int
5533 and select._simple_int_clause(offset_clause)
5534 ):
5535 offset_clause = offset_clause.render_literal_execute()
5536 offset_str = self.process(offset_clause, **kw)
5537 text += "\n OFFSET %s ROWS" % offset_str
5538 elif require_offset:
5539 text += "\n OFFSET 0 ROWS"
5540
5541 if fetch_clause is not None:
5542 if (
5543 use_literal_execute_for_simple_int
5544 and select._simple_int_clause(fetch_clause)
5545 ):
5546 fetch_clause = fetch_clause.render_literal_execute()
5547 text += "\n FETCH FIRST %s%s ROWS %s" % (
5548 self.process(fetch_clause, **kw),
5549 " PERCENT" if fetch_clause_options["percent"] else "",
5550 "WITH TIES" if fetch_clause_options["with_ties"] else "ONLY",
5551 )
5552 return text
5553
5554 def visit_table(
5555 self,

Callers 1

_row_limit_clauseMethod · 0.95

Calls 3

_simple_int_clauseMethod · 0.80
processMethod · 0.45

Tested by

no test coverage detected