(t *testing.T)
| 1069 | } |
| 1070 | |
| 1071 | func TestQueryLifeCycle(t *testing.T) { |
| 1072 | testWithAllQueryExecModes(t, func(t *testing.T, db *sql.DB) { |
| 1073 | skipCockroachDB(t, db, "Server issues incorrect ParameterDescription (https://github.com/cockroachdb/cockroach/issues/60907)") |
| 1074 | |
| 1075 | rows, err := db.Query("SELECT 'foo', n FROM generate_series($1::int, $2::int) n WHERE 3 = $3", 1, 10, 3) |
| 1076 | require.NoError(t, err) |
| 1077 | |
| 1078 | rowCount := int64(0) |
| 1079 | |
| 1080 | for rows.Next() { |
| 1081 | rowCount++ |
| 1082 | var ( |
| 1083 | s string |
| 1084 | n int64 |
| 1085 | ) |
| 1086 | |
| 1087 | err := rows.Scan(&s, &n) |
| 1088 | require.NoError(t, err) |
| 1089 | |
| 1090 | if s != "foo" { |
| 1091 | t.Errorf(`Expected "foo", received "%v"`, s) |
| 1092 | } |
| 1093 | |
| 1094 | if n != rowCount { |
| 1095 | t.Errorf("Expected %d, received %d", rowCount, n) |
| 1096 | } |
| 1097 | } |
| 1098 | require.NoError(t, rows.Err()) |
| 1099 | |
| 1100 | err = rows.Close() |
| 1101 | require.NoError(t, err) |
| 1102 | |
| 1103 | rows, err = db.Query("select 1 where false") |
| 1104 | require.NoError(t, err) |
| 1105 | |
| 1106 | rowCount = int64(0) |
| 1107 | |
| 1108 | for rows.Next() { |
| 1109 | rowCount++ |
| 1110 | } |
| 1111 | require.NoError(t, rows.Err()) |
| 1112 | require.EqualValues(t, 0, rowCount) |
| 1113 | |
| 1114 | err = rows.Close() |
| 1115 | require.NoError(t, err) |
| 1116 | }) |
| 1117 | } |
| 1118 | |
| 1119 | // https://github.com/jackc/pgx/issues/409 |
| 1120 | func TestScanJSONIntoJSONRawMessage(t *testing.T) { |
nothing calls this directly
no test coverage detected