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

Method test_annotated_fetch

test/sql/test_external_traversal.py:525–572  ·  view source on GitHub ↗

test #9526

(self, limit_type: testing.Variation, dialect)

Source from the content-addressed store, hash-verified

523 @testing.variation("limit_type", ["limit", "fetch"])
524 @testing.variation("dialect", ["default", "oracle"])
525 def test_annotated_fetch(self, limit_type: testing.Variation, dialect):
526 """test #9526"""
527
528 if limit_type.limit:
529 stmt = select(column("q")).limit(1)
530 elif limit_type.fetch:
531 stmt = select(column("q")).fetch(1)
532 else:
533 limit_type.fail()
534
535 stmt = _deep_annotate(stmt, {"foo": "bar"})
536
537 if limit_type.limit:
538 if dialect.default:
539 self.assert_compile(
540 stmt,
541 "SELECT q LIMIT :param_1",
542 use_literal_execute_for_simple_int=True,
543 dialect=dialect.name,
544 )
545 elif dialect.oracle:
546 self.assert_compile(
547 stmt,
548 "SELECT q FROM DUAL FETCH FIRST "
549 "__[POSTCOMPILE_param_1] ROWS ONLY",
550 dialect=dialect.name,
551 )
552 else:
553 dialect.fail()
554 elif limit_type.fetch:
555 if dialect.default:
556 self.assert_compile(
557 stmt,
558 "SELECT q FETCH FIRST __[POSTCOMPILE_param_1] ROWS ONLY",
559 use_literal_execute_for_simple_int=True,
560 dialect=dialect.name,
561 )
562 elif dialect.oracle:
563 self.assert_compile(
564 stmt,
565 "SELECT q FROM DUAL FETCH FIRST "
566 "__[POSTCOMPILE_param_1] ROWS ONLY",
567 dialect=dialect.name,
568 )
569 else:
570 dialect.fail()
571 else:
572 limit_type.fail()
573
574 @testing.combinations((null(),), (true(),))
575 def test_dont_adapt_singleton_elements(self, elem):

Callers

nothing calls this directly

Calls 7

selectFunction · 0.90
columnFunction · 0.90
_deep_annotateFunction · 0.85
fetchMethod · 0.80
assert_compileMethod · 0.80
limitMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected