-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
@@ -146,6 +146,12 @@ components: | |||
query: | |||
type: string | |||
description: Query to run, given as a SQL string. | |||
params: | |||
type: object | |||
description: > |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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;" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
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? -
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.
There was a problem hiding this comment.
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?
4e85431
to
da1e7d0
Compare
No description provided.