fix(chart): non existent time grain no longer breaks the application (#23441)

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
This commit is contained in:
Rémy DUBOIS 2023-03-23 15:36:50 +01:00 committed by GitHub
parent b0773145d6
commit 07a632891c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -704,7 +704,7 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
time_grain_expressions.update(grain_addon_expressions.get(cls.engine, {}))
denylist: List[str] = current_app.config["TIME_GRAIN_DENYLIST"]
for key in denylist:
time_grain_expressions.pop(key)
time_grain_expressions.pop(key, None)
return dict(
sorted(

View File

@ -332,11 +332,12 @@ def test_is_readonly():
def test_time_grain_denylist():
config = app.config.copy()
app.config["TIME_GRAIN_DENYLIST"] = ["PT1M"]
app.config["TIME_GRAIN_DENYLIST"] = ["PT1M", "SQLITE_NONEXISTENT_GRAIN"]
with app.app_context():
time_grain_functions = SqliteEngineSpec.get_time_grain_expressions()
assert not "PT1M" in time_grain_functions
assert not "SQLITE_NONEXISTENT_GRAIN" in time_grain_functions
app.config = config