From e75b85c8917d070030d78b59a4bffe4cb6f19e48 Mon Sep 17 00:00:00 2001 From: Fantix King Date: Thu, 13 Feb 2025 18:59:10 -0500 Subject: [PATCH] bug fix: auto_rebuild_query_cache gate was broken (#8339) Broken in #8276 --- edb/server/config/__init__.py | 1 + edb/server/dbview/dbview.pyx | 2 +- tests/test_server_ops.py | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/edb/server/config/__init__.py b/edb/server/config/__init__.py index c3420ae0272..50c147e9885 100644 --- a/edb/server/config/__init__.py +++ b/edb/server/config/__init__.py @@ -77,6 +77,7 @@ def lookup( spec: Spec, allow_unrecognized: bool = False, ) -> Any: + assert len(configs) > 0 try: setting = spec[name] diff --git a/edb/server/dbview/dbview.pyx b/edb/server/dbview/dbview.pyx index 3fc2c22ce64..49574d6dced 100644 --- a/edb/server/dbview/dbview.pyx +++ b/edb/server/dbview/dbview.pyx @@ -1440,7 +1440,7 @@ cdef class DatabaseConnectionView: if unit.user_schema: user_schema = unit.user_schema user_schema_version = unit.user_schema_version - if user_schema and not self.server.config_lookup( + if user_schema and not self.config_lookup( "auto_rebuild_query_cache", ): user_schema = None diff --git a/tests/test_server_ops.py b/tests/test_server_ops.py index 2410c312914..779c833ba3a 100644 --- a/tests/test_server_ops.py +++ b/tests/test_server_ops.py @@ -864,6 +864,27 @@ def measure_sql_compilations( # con_c = con.with_config(apply_access_policies=False) # await con_c.query_sql(qry_sql) + # At last, make sure recompilation switch works fine + await con.execute( + "configure current database " + "set auto_rebuild_query_cache := false" + ) + await con.query(''' + create type X + ''') + with self.assertChange(measure_compilations(sd), 1): + await con.query(qry) + with self.assertChange(measure_compilations(sd), 0): + await con.query(qry) + with self.assertChange(measure_sql_compilations(sd), 1): + await con.query_sql(sql) + with self.assertChange(measure_sql_compilations(sd), 0): + await con.query_sql(sql) + await con.execute( + "configure current database " + "reset auto_rebuild_query_cache" + ) + finally: await con.aclose()