MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_annotated_fetch

Method test_annotated_fetch

test/sql/test_external_traversal.py:526–573  ·  view source on GitHub ↗

test #9526

(self, limit_type: testing.Variation, dialect)

Source from the content-addressed store, hash-verified

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

Tested by

no test coverage detected