From 0e8d80100e3d7c104747f336a8b19991d6a607c3 Mon Sep 17 00:00:00 2001 From: Fantix King Date: Sat, 7 Dec 2024 10:06:13 -0500 Subject: [PATCH] Fix config bugs with env vars and default checking (#8078) * Fix multiprop config bug reading from env var * Fix to use the right MISSING from statypes --- edb/ir/staeval.py | 3 +-- edb/server/main.py | 2 ++ tests/test_server_config.py | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/edb/ir/staeval.py b/edb/ir/staeval.py index 4ff93d2f90f..162bf69f6ea 100644 --- a/edb/ir/staeval.py +++ b/edb/ir/staeval.py @@ -32,7 +32,6 @@ FrozenSet, ) -import dataclasses import decimal import functools @@ -531,7 +530,7 @@ def object_type_to_spec( default = p.get_default(schema) if default is None: if p.get_required(schema): - default = dataclasses.MISSING + default = statypes.MISSING else: default = qlcompiler.evaluate_to_python_val( default.text, schema=schema) diff --git a/edb/server/main.py b/edb/server/main.py index c5dbf4e9394..4352c87d0bc 100644 --- a/edb/server/main.py +++ b/edb/server/main.py @@ -889,6 +889,8 @@ def iter_environ(): env_value = env_value == 'true' elif not issubclass(setting.type, statypes.ScalarType): # type: ignore env_value = setting.type(env_value) # type: ignore + if setting.set_of: + env_value = (env_value,) add_config(cfg_name, env_value, environment_variable) if args.bind_addresses: diff --git a/tests/test_server_config.py b/tests/test_server_config.py index dcc53b10730..4c2ef9e1177 100644 --- a/tests/test_server_config.py +++ b/tests/test_server_config.py @@ -2165,6 +2165,7 @@ async def test_server_config_env_01(self): "EDGEDB_SERVER_CONFIG_cfg::session_idle_timeout": "1m22s", "EDGEDB_SERVER_CONFIG_cfg::query_execution_timeout": "403", "EDGEDB_SERVER_CONFIG_cfg::apply_access_policies": "false", + "EDGEDB_SERVER_CONFIG_cfg::multiprop": "single", } async with tb.start_edgedb_server(env=env) as sd: conn = await sd.connect() @@ -2193,6 +2194,12 @@ async def test_server_config_env_01(self): select assert_single(cfg::Config.apply_access_policies) """) ) + self.assertEqual( + await conn.query("""\ + select assert_single(cfg::Config).multiprop + """), + ["single"], + ) finally: await conn.aclose()