diff --git a/proxy/src/http/sql_over_http.rs b/proxy/src/http/sql_over_http.rs index 736413c85c3b..aa06a91bbae9 100644 --- a/proxy/src/http/sql_over_http.rs +++ b/proxy/src/http/sql_over_http.rs @@ -27,11 +27,16 @@ struct QueryData { params: Vec, } +#[derive(serde::Deserialize)] +struct BatchQueryData { + queries: Vec, +} + #[derive(serde::Deserialize)] #[serde(untagged)] enum Payload { Single(QueryData), - Batch(Vec), + Batch(BatchQueryData), } pub const MAX_RESPONSE_SIZE: usize = 10 * 1024 * 1024; // 10 MB @@ -233,7 +238,7 @@ pub async fn handle( Payload::Single(query) => query_to_json(&client, query, raw_output, array_mode) .await .map(|x| (x, HashMap::default())), - Payload::Batch(queries) => { + Payload::Batch(batch_query) => { let mut results = Vec::new(); let mut builder = client.build_transaction(); if let Some(isolation_level) = txn_isolation_level { @@ -243,7 +248,7 @@ pub async fn handle( builder = builder.read_only(true); } let transaction = builder.start().await?; - for query in queries { + for query in batch_query.queries { let result = query_to_json(&transaction, query, raw_output, array_mode).await; match result { Ok(r) => results.push(r), diff --git a/test_runner/regress/test_proxy.py b/test_runner/regress/test_proxy.py index 35334ec7b245..fabec6b5bc3e 100644 --- a/test_runner/regress/test_proxy.py +++ b/test_runner/regress/test_proxy.py @@ -269,7 +269,9 @@ def qq(queries: List[Tuple[str, Optional[List[Any]]]], read_only: bool = False) connstr = f"postgresql://http:http@{static_proxy.domain}:{static_proxy.proxy_port}/postgres" response = requests.post( f"https://{static_proxy.domain}:{static_proxy.external_http_port}/sql", - data=json.dumps(list(map(lambda x: {"query": x[0], "params": x[1] or []}, queries))), + data=json.dumps( + {"queries": list(map(lambda x: {"query": x[0], "params": x[1] or []}, queries))} + ), headers={ "Content-Type": "application/sql", "Neon-Connection-String": connstr,