-
Notifications
You must be signed in to change notification settings - Fork 26
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
An optional values
parameter in the exec
method
#290
Conversation
@@ -214,10 +226,14 @@ export class ClickHouseClient<Stream = unknown> { | |||
* but format clause is not applicable. The caller of this method is expected to consume the stream, | |||
* otherwise, the request will eventually be timed out. | |||
*/ | |||
async exec(params: ExecParams): Promise<ExecResult<Stream>> { | |||
async exec( | |||
params: ExecParams | ExecParamsWithValues<Stream>, |
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.
I avoided parametrizing ExecParams in this case, as it's a bit tricky to maintain full backward compatibility.
const { controller, controllerCleanup } = this.getAbortController(params) | ||
try { | ||
const { stream, summary, response_headers } = await this.request( | ||
{ | ||
method: 'POST', | ||
url: transformUrl({ url: this.params.url, searchParams }), | ||
body: params.query, | ||
body: sendQueryInParams ? params.values : params.query, |
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.
nit: I'd prefer to keep a single logic path to send a request, but let's postpone until the next major release when we can always send query
in URL and values
as body (even if it's empty)
Quality Gate passedIssues Measures |
Summary
The
exec
method now accepts an optionalvalues
parameter, which allows you to pass the request body as aStream.Readable
. This can be useful in case of custom insert streaming with arbitrary ClickHouse data formats (which might not be explicitly supported and allowed by the client in theinsert
method yet).A very minimal example with CSV (from the tests, it does not make sense as CSV is supported via the normal
insert
, just an illustration):Checklist