MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_insert

Method test_insert

test/sql/test_defaults.py:548–624  ·  view source on GitHub ↗
(self, connection)

Source from the content-addressed store, hash-verified

546 assert isinstance(ctexec, datetime.date)
547
548 def test_insert(self, connection):
549 t = self.tables.default_test
550
551 r = connection.execute(t.insert())
552 assert r.lastrow_has_defaults()
553 eq_(
554 set(r.context.postfetch_cols),
555 {t.c.col3, t.c.col5, t.c.col4, t.c.col6},
556 )
557
558 r = connection.execute(t.insert().inline())
559 assert r.lastrow_has_defaults()
560 eq_(
561 set(r.context.postfetch_cols),
562 {t.c.col3, t.c.col5, t.c.col4, t.c.col6},
563 )
564
565 connection.execute(t.insert())
566
567 ctexec = connection.execute(
568 sa.select(self.currenttime.label("now"))
569 ).scalar()
570 result = connection.execute(t.select().order_by(t.c.col1))
571 today = datetime.date.today()
572 eq_(
573 list(result),
574 [
575 (
576 x,
577 "imthedefault",
578 self.f,
579 self.ts,
580 self.ts,
581 ctexec,
582 True,
583 False,
584 12,
585 today,
586 "py",
587 "hi",
588 "BINDfoo",
589 )
590 for x in range(51, 54)
591 ],
592 )
593
594 connection.execute(t.insert(), dict(col9=None))
595
596 # TODO: why are we looking at 'r' when we just executed something
597 # else ?
598 assert r.lastrow_has_defaults()
599
600 eq_(
601 set(r.context.postfetch_cols),
602 {t.c.col3, t.c.col5, t.c.col4, t.c.col6},
603 )
604
605 eq_(

Callers

nothing calls this directly

Calls 10

eq_Function · 0.90
executeMethod · 0.45
insertMethod · 0.45
lastrow_has_defaultsMethod · 0.45
inlineMethod · 0.45
scalarMethod · 0.45
selectMethod · 0.45
labelMethod · 0.45
order_byMethod · 0.45
whereMethod · 0.45

Tested by

no test coverage detected