(conn)
| 497 | |
| 498 | |
| 499 | def test_copy_in_text_no_pinning(conn): |
| 500 | cur = conn.cursor() |
| 501 | cur.adapters.register_dumper(int, StrictIntDumper) |
| 502 | |
| 503 | cols = [ |
| 504 | "col1 serial primary key", |
| 505 | "col2 int", |
| 506 | "col3 int", |
| 507 | "col4 double precision", |
| 508 | "col5 double precision", |
| 509 | ] |
| 510 | ensure_table(cur, ",".join(cols)) |
| 511 | |
| 512 | with cur.copy( |
| 513 | "copy copy_in (col2,col3,col4,col5) from stdin (format text)" |
| 514 | ) as copy: |
| 515 | # no pinned dumpers: type check & cast done on postgres side |
| 516 | # allows to mix castable reprs more freely |
| 517 | # slower than pinned, late errors from postgres jeopardizing copy cursor |
| 518 | copy.write_row([1, "2", 3, "4.1"]) |
| 519 | copy.write_row(["1", 2, 3.0, 4]) |
| 520 | |
| 521 | cur.execute("select col2,col3,col4,col5 from copy_in order by 1") |
| 522 | data = cur.fetchall() |
| 523 | assert data == [(1, 2, 3, 4.1), (1, 2, 3, 4)] |
| 524 | |
| 525 | |
| 526 | def test_copy_in_text_pinned(conn): |
nothing calls this directly
no test coverage detected