MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_upsert_downgrades

Method test_upsert_downgrades

test/sql/test_insert_exec.py:2775–2887  ·  view source on GitHub ↗
(
        self,
        metadata,
        connection,
        pk_type: testing.Variation,
        sort_by_parameter_order,
        randomize_returning,
        sentinel_type,
        warn_for_downgrades,
    )

Source from the content-addressed store, hash-verified

2773 )
2774 @testing.requires.provisioned_upsert
2775 def test_upsert_downgrades(
2776 self,
2777 metadata,
2778 connection,
2779 pk_type: testing.Variation,
2780 sort_by_parameter_order,
2781 randomize_returning,
2782 sentinel_type,
2783 warn_for_downgrades,
2784 ):
2785 if pk_type.serverside:
2786 pk_col = Column(
2787 "id",
2788 Integer(),
2789 primary_key=True,
2790 insert_sentinel=bool(sentinel_type.use_pk_explicit),
2791 )
2792 elif pk_type.clientside:
2793 pk_col = Column(
2794 "id",
2795 Uuid(),
2796 default=uuid.uuid4,
2797 primary_key=True,
2798 insert_sentinel=bool(sentinel_type.use_pk_explicit),
2799 )
2800 else:
2801 pk_type.fail()
2802
2803 if sentinel_type.separate_uuid:
2804 extra_col = Column(
2805 "sent_col",
2806 Uuid(),
2807 default=uuid.uuid4,
2808 insert_sentinel=True,
2809 nullable=False,
2810 )
2811 elif sentinel_type.separate_sentinel:
2812 extra_col = insert_sentinel("sent_col")
2813 else:
2814 extra_col = Column("sent_col", Integer)
2815
2816 t1 = Table(
2817 "upsert_table",
2818 metadata,
2819 pk_col,
2820 Column("data", String(50)),
2821 extra_col,
2822 Column(
2823 "has_server_default",
2824 String(30),
2825 server_default="some_server_default",
2826 ),
2827 )
2828 metadata.create_all(connection)
2829
2830 result = connection.execute(
2831 insert(t1).returning(
2832 t1.c.id, t1.c.data, sort_by_parameter_order=True

Callers

nothing calls this directly

Calls 13

ColumnClass · 0.90
IntegerClass · 0.90
UuidClass · 0.90
insert_sentinelFunction · 0.90
TableClass · 0.90
StringClass · 0.90
insertFunction · 0.90
eq_Function · 0.90
create_allMethod · 0.80
failMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected