Skip to content

Allow query parameters to be passed with query#184

Merged
kislyuk merged 6 commits intomasterfrom
akislyuk-query-params
Jun 13, 2019
Merged

Allow query parameters to be passed with query#184
kislyuk merged 6 commits intomasterfrom
akislyuk-query-params

Conversation

@kislyuk
Copy link
Copy Markdown
Member

@kislyuk kislyuk commented Jun 8, 2019

No description provided.

@kislyuk kislyuk requested a review from MDunitz June 8, 2019 23:26
description: Query to run, given as a SQL string.
params:
type: object
description: >
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

self.assertEqual(response.json['query'], query)
self.assertGreaterEqual(response.json['results'][0]['count'], 0)

query = "SELECT count(*) FROM FILES WHERE SIZE > :s;"
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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