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

fix columns names in InvalidResultColumnNames being reported the wrong way round #185

Conversation

andrewjw
Copy link
Contributor

Hi,

The parameters for InvalidResultColumnNames are (expected, got), but they are called as (result_keys, expected_keys). This leads to a slightly confusing error message if you get your query wrong.

Hope this is useful!

Andrew

Copy link
Owner

@albertodonato albertodonato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Mind also adding the following change for the existing test?

diff --git a/tests/db_test.py b/tests/db_test.py
index 28f7e32..bdac907 100644
--- a/tests/db_test.py
+++ b/tests/db_test.py
@@ -292,8 +292,12 @@ class TestQuery:
             "query", ["db"], [QueryMetric("metric1", ["label1"])], ""
         )
         query_results = QueryResults(["one", "two"], [(1, 2)])
-        with pytest.raises(InvalidResultColumnNames):
+        with pytest.raises(InvalidResultColumnNames) as error:
             query.results(query_results)
+        assert str(error.value) == (
+            "Wrong column names from query: "
+            "expected (label1, metric1), got (one, two)"
+        )

@albertodonato
Copy link
Owner

Nevermind, I've pushed a commit with that change (also fixing a failing test).

@albertodonato albertodonato merged commit 1bc8aa0 into albertodonato:main Jan 25, 2024
5 checks passed
@albertodonato
Copy link
Owner

Thanks for reporting and fixing the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants