Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend QueryManager query type #9874

Merged
merged 3 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions datadog_checks_base/datadog_checks/base/utils/db/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def compile(
query = self.query_data.get('query')
if not query:
raise ValueError('field `query` for {} is required'.format(query_name))
elif not isinstance(query, str):
raise ValueError('field `query` for {} must be a string'.format(query_name))
elif not isinstance(query, str) and not isinstance(query, dict):
mx-psi marked this conversation as resolved.
Show resolved Hide resolved
raise ValueError('field `query` for {} must be a string or a mapping'.format(query_name))

columns = self.query_data.get('columns')
if not columns:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def test_no_query(self):
with pytest.raises(ValueError, match='^field `query` for test query is required$'):
query_manager.compile_queries()

def test_query_not_string(self):
def test_query_not_string_or_dict(self):
query_manager = create_query_manager({'name': 'test query', 'query': 5})

with pytest.raises(ValueError, match='^field `query` for test query must be a string$'):
with pytest.raises(ValueError, match='^field `query` for test query must be a string or a mapping$'):
query_manager.compile_queries()

def test_no_columns(self):
Expand Down