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

Allow query parameters to be passed with query #184

Merged
merged 6 commits into from
Jun 13, 2019
Merged

Conversation

kislyuk
Copy link
Member

@kislyuk kislyuk commented Jun 8, 2019

No description provided.

@kislyuk kislyuk requested a review from MDunitz June 8, 2019 23:26
@@ -146,6 +146,12 @@ components:
query:
type: string
description: Query to run, given as a SQL string.
params:
type: object
description: >
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you include an example that shows how this helps avoid the escaping issue

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, absolutely, but I would like to merge HumanCellAtlas/dcp-cli#359 first, and make a complete suite of documentation including the use of this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Filed #187 to track this.

@@ -31,6 +31,14 @@ def test_query(self):
self.assertEqual(response.json['query'], query)
self.assertGreaterEqual(response.json['results'][0]['count'], 0)

query = "SELECT count(*) FROM FILES WHERE SIZE > :s;"
Copy link
Collaborator

Choose a reason for hiding this comment

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

would it be worth it to add a test showing this gives the same result as running the query without params
"SELECT count(*) FROM FILES WHERE SIZE > 0;"
Also would it be worth it to return the query that was actually run with the params in place to help debug issues?

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. Yes, but if the database undergoes a change in the number of files as we run the test, the result will change. So we need some way to ensure atomicity in the test. I tried passing multiple queries (select count(*) from files; select count(*) from files where size > 0; but the first result gets shadowed by the second. Do you know how to ensure atomicity?

  2. Yes, that's a great idea but I'd like to tackle it separately. Filed Return formatted query in addition to input query with results #186 to track that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe if you reset the db connection between queries?

@kislyuk kislyuk force-pushed the akislyuk-query-params branch from 4e85431 to da1e7d0 Compare June 13, 2019 20:11
@kislyuk kislyuk merged commit 864385a into master Jun 13, 2019
@kislyuk kislyuk deleted the akislyuk-query-params branch June 13, 2019 20:28
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.

2 participants