(t *testing.T)
| 1240 | } |
| 1241 | |
| 1242 | func TestConnExecParamsDeferredError(t *testing.T) { |
| 1243 | t.Parallel() |
| 1244 | |
| 1245 | ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second) |
| 1246 | defer cancel() |
| 1247 | |
| 1248 | pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE")) |
| 1249 | require.NoError(t, err) |
| 1250 | defer closeConn(t, pgConn) |
| 1251 | |
| 1252 | if pgConn.ParameterStatus("crdb_version") != "" { |
| 1253 | t.Skip("Server does not support deferred constraint (https://github.com/cockroachdb/cockroach/issues/31632)") |
| 1254 | } |
| 1255 | |
| 1256 | setupSQL := `create temporary table t ( |
| 1257 | id text primary key, |
| 1258 | n int not null, |
| 1259 | unique (n) deferrable initially deferred |
| 1260 | ); |
| 1261 | |
| 1262 | insert into t (id, n) values ('a', 1), ('b', 2), ('c', 3);` |
| 1263 | |
| 1264 | _, err = pgConn.Exec(ctx, setupSQL).ReadAll() |
| 1265 | assert.NoError(t, err) |
| 1266 | |
| 1267 | result := pgConn.ExecParams(ctx, `update t set n=n+1 where id='b' returning *`, nil, nil, nil, nil).Read() |
| 1268 | require.NotNil(t, result.Err) |
| 1269 | var pgErr *pgconn.PgError |
| 1270 | require.True(t, errors.As(result.Err, &pgErr)) |
| 1271 | require.Equal(t, "23505", pgErr.Code) |
| 1272 | |
| 1273 | ensureConnValid(t, pgConn) |
| 1274 | } |
| 1275 | |
| 1276 | func TestConnExecParamsMaxNumberOfParams(t *testing.T) { |
| 1277 | t.Parallel() |
nothing calls this directly
no test coverage detected