| 2275 | @testing.variation("native_uuid", [True, False]) |
| 2276 | @testing.variation("as_uuid", [True, False]) |
| 2277 | def test_client_composite_pk( |
| 2278 | self, |
| 2279 | metadata, |
| 2280 | connection, |
| 2281 | randomize_returning, |
| 2282 | sort_by_parameter_order, |
| 2283 | warn_for_downgrades, |
| 2284 | native_uuid, |
| 2285 | as_uuid, |
| 2286 | ): |
| 2287 | uuids = [uuid.uuid4() for i in range(10)] |
| 2288 | if not as_uuid: |
| 2289 | uuids = [str(u) for u in uuids] |
| 2290 | |
| 2291 | t1 = Table( |
| 2292 | "data", |
| 2293 | metadata, |
| 2294 | Column( |
| 2295 | "id1", |
| 2296 | Uuid(as_uuid=bool(as_uuid), native_uuid=bool(native_uuid)), |
| 2297 | default=functools.partial(next, iter(uuids)), |
| 2298 | primary_key=True, |
| 2299 | ), |
| 2300 | Column( |
| 2301 | "id2", |
| 2302 | # note this is testing that plain populated PK cols |
| 2303 | # also qualify as sentinels since they have to be there |
| 2304 | String(30), |
| 2305 | primary_key=True, |
| 2306 | ), |
| 2307 | Column("data", String(50)), |
| 2308 | Column( |
| 2309 | "has_server_default", |
| 2310 | String(30), |
| 2311 | server_default="some_server_default", |
| 2312 | ), |
| 2313 | ) |
| 2314 | metadata.create_all(connection) |
| 2315 | |
| 2316 | fixtures.insertmanyvalues_fixture( |
| 2317 | connection, |
| 2318 | randomize_rows=bool(randomize_returning), |
| 2319 | warn_on_downgraded=bool(warn_for_downgrades), |
| 2320 | ) |
| 2321 | |
| 2322 | result = connection.execute( |
| 2323 | insert(t1).returning( |
| 2324 | t1.c.id1, |
| 2325 | t1.c.id2, |
| 2326 | t1.c.data, |
| 2327 | t1.c.has_server_default, |
| 2328 | sort_by_parameter_order=bool(sort_by_parameter_order), |
| 2329 | ), |
| 2330 | [{"id2": f"id{i}", "data": f"d{i}"} for i in range(10)], |
| 2331 | ) |
| 2332 | |
| 2333 | if sort_by_parameter_order: |
| 2334 | coll = list |