(t *testing.T)
| 389 | } |
| 390 | |
| 391 | func TestExecPerQuerySimpleProtocol(t *testing.T) { |
| 392 | t.Parallel() |
| 393 | |
| 394 | conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE")) |
| 395 | defer closeConn(t, conn) |
| 396 | |
| 397 | ctx := t.Context() |
| 398 | |
| 399 | commandTag, err := conn.Exec(ctx, "create temporary table foo(name varchar primary key);") |
| 400 | if err != nil { |
| 401 | t.Fatal(err) |
| 402 | } |
| 403 | if commandTag.String() != "CREATE TABLE" { |
| 404 | t.Fatalf("Unexpected results from Exec: %v", commandTag) |
| 405 | } |
| 406 | |
| 407 | commandTag, err = conn.Exec(ctx, |
| 408 | "insert into foo(name) values($1);", |
| 409 | pgx.QueryExecModeSimpleProtocol, |
| 410 | "bar'; drop table foo;--", |
| 411 | ) |
| 412 | if err != nil { |
| 413 | t.Fatal(err) |
| 414 | } |
| 415 | if commandTag.String() != "INSERT 0 1" { |
| 416 | t.Fatalf("Unexpected results from Exec: %v", commandTag) |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | func TestPrepare(t *testing.T) { |
| 421 | t.Parallel() |
nothing calls this directly
no test coverage detected