(
compiler, _column_as_key, bindmarkers, compile_state, values, kw
)
| 457 | |
| 458 | |
| 459 | def _replace_bindmarkers( |
| 460 | compiler, _column_as_key, bindmarkers, compile_state, values, kw |
| 461 | ): |
| 462 | _expr_by_col_key = { |
| 463 | _column_as_key(col): compiled_str for col, _, compiled_str, _ in values |
| 464 | } |
| 465 | |
| 466 | def replace_marker(m): |
| 467 | try: |
| 468 | return _expr_by_col_key[m.group(1)] |
| 469 | except KeyError as ke: |
| 470 | if dml.isupdate(compile_state): |
| 471 | return compiler.process(bindmarkers[m.group(1)].column, **kw) |
| 472 | else: |
| 473 | raise exc.CompileError( |
| 474 | f"Can't resolve referenced column name in " |
| 475 | f"INSERT statement: {m.group(1)!r}" |
| 476 | ) from ke |
| 477 | |
| 478 | values[:] = [ |
| 479 | ( |
| 480 | col, |
| 481 | col_value, |
| 482 | re.sub( |
| 483 | r"__BINDMARKER_~~(.+?)~~", |
| 484 | replace_marker, |
| 485 | compiled_str, |
| 486 | ), |
| 487 | accumulated_bind_names, |
| 488 | ) |
| 489 | for ( |
| 490 | col, |
| 491 | col_value, |
| 492 | compiled_str, |
| 493 | accumulated_bind_names, |
| 494 | ) in values |
| 495 | ] |
| 496 | |
| 497 | |
| 498 | @overload |
no test coverage detected