Skip to content

Commit

Permalink
Fix config bugs with env vars and default checking (#8078)
Browse files Browse the repository at this point in the history
* Fix multiprop config bug reading from env var
* Fix to use the right MISSING from statypes
  • Loading branch information
fantix authored Dec 7, 2024
1 parent 473a15c commit 0e8d801
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 1 addition & 2 deletions edb/ir/staeval.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
FrozenSet,
)

import dataclasses
import decimal
import functools

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions edb/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions tests/test_server_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 0e8d801

Please sign in to comment.