mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-26 17:40:37 +00:00
proxy: add per query array mode flag (#6678)
## Problem Drizzle needs to be able to configure the array_mode flag per query. ## Summary of changes Adds an array_mode flag to the query data json that will otherwise default to the header flag.
This commit is contained in:
@@ -390,6 +390,39 @@ def test_sql_over_http_batch(static_proxy: NeonProxy):
|
||||
assert result[0]["rows"] == [{"answer": 42}]
|
||||
|
||||
|
||||
def test_sql_over_http_batch_output_options(static_proxy: NeonProxy):
|
||||
static_proxy.safe_psql("create role http with login password 'http' superuser")
|
||||
|
||||
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(
|
||||
{
|
||||
"queries": [
|
||||
{"query": "select $1 as answer", "params": [42], "arrayMode": True},
|
||||
{"query": "select $1 as answer", "params": [42], "arrayMode": False},
|
||||
]
|
||||
}
|
||||
),
|
||||
headers={
|
||||
"Content-Type": "application/sql",
|
||||
"Neon-Connection-String": connstr,
|
||||
"Neon-Batch-Isolation-Level": "Serializable",
|
||||
"Neon-Batch-Read-Only": "false",
|
||||
"Neon-Batch-Deferrable": "false",
|
||||
},
|
||||
verify=str(static_proxy.test_output_dir / "proxy.crt"),
|
||||
)
|
||||
assert response.status_code == 200
|
||||
results = response.json()["results"]
|
||||
|
||||
assert results[0]["rowAsArray"]
|
||||
assert results[0]["rows"] == [["42"]]
|
||||
|
||||
assert not results[1]["rowAsArray"]
|
||||
assert results[1]["rows"] == [{"answer": "42"}]
|
||||
|
||||
|
||||
def test_sql_over_http_pool(static_proxy: NeonProxy):
|
||||
static_proxy.safe_psql("create user http_auth with password 'http' superuser")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user