feat: Add compatibility with connection poolers on transaction mode

Update the hasql-transaction library to version 1.0.1

Add hints and kill thread at configuration read when using incompatible pooling modes: statement pooling and transaction pooling with prepared statements enabled.
This commit is contained in:
laurenceisla
2021-07-15 13:39:55 -05:00
committed by GitHub
parent 83cc358e1b
commit db95bd1c37
8 changed files with 70 additions and 25 deletions
+4 -3
View File
@@ -2041,9 +2041,10 @@ returns setof v2.parents as $$
select * from v2.parents where id < $1;
$$ language sql;
-- Only used for manually testing creating prepared statements
create view prepared_statements as
select * from pg_catalog.pg_prepared_statements;
-- Used to test if prepared statements are used
create function uses_prepared_statements() returns bool as $$
select count(name) > 0 from pg_catalog.pg_prepared_statements
$$ language sql;
create or replace function change_max_rows_config(val int, notify bool default false) returns void as $_$
begin
+19
View File
@@ -708,3 +708,22 @@ def test_invalid_role_claim_key_notify_reload(defaultenv):
)
postgrest.session.post("/rpc/reset_invalid_role_claim_key")
def test_db_prepared_statements_enable(defaultenv):
"Should use prepared statements when the setting is enabled."
with run(env=defaultenv) as postgrest:
response = postgrest.session.post("/rpc/uses_prepared_statements")
assert response.text == "true"
def test_db_prepared_statements_disable(defaultenv):
"Should not use any prepared statements when the setting is disabled."
env = {
**defaultenv,
"PGRST_DB_PREPARED_STATEMENTS": "false",
}
with run(env=env) as postgrest:
response = postgrest.session.post("/rpc/uses_prepared_statements")
assert response.text == "false"