@clickhouse/client-common
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -16,2 +16,3 @@ export interface ResponseJSON<T = unknown> { | ||
rows?: number; | ||
rows_before_limit_at_least?: number; | ||
} | ||
@@ -18,0 +19,0 @@ export interface InputJSON<T = unknown> { |
@@ -89,4 +89,4 @@ import type { BaseClickHouseClientConfigOptions, ClickHouseSettings, ConnExecResult, IsSame, WithClickHouseSummary } from '@clickhouse/client-common'; | ||
private readonly valuesEncoder; | ||
private readonly closeStream; | ||
private readonly sessionId?; | ||
private readonly logWriter; | ||
constructor(config: BaseClickHouseClientConfigOptions & ImplementationDetails<Stream>); | ||
@@ -93,0 +93,0 @@ /** |
@@ -32,3 +32,3 @@ "use strict"; | ||
}); | ||
Object.defineProperty(this, "closeStream", { | ||
Object.defineProperty(this, "sessionId", { | ||
enumerable: true, | ||
@@ -39,3 +39,3 @@ configurable: true, | ||
}); | ||
Object.defineProperty(this, "sessionId", { | ||
Object.defineProperty(this, "logWriter", { | ||
enumerable: true, | ||
@@ -51,2 +51,3 @@ configurable: true, | ||
const connectionParams = (0, config_1.getConnectionParams)(configWithURL, logger); | ||
this.logWriter = connectionParams.log_writer; | ||
this.clientClickHouseSettings = connectionParams.clickhouse_settings; | ||
@@ -57,3 +58,2 @@ this.sessionId = config.session_id; | ||
this.valuesEncoder = config.impl.values_encoder; | ||
this.closeStream = config.impl.close_stream; | ||
} | ||
@@ -74,3 +74,14 @@ /** | ||
}); | ||
return this.makeResultSet(stream, format, query_id); | ||
return this.makeResultSet(stream, format, query_id, (err) => { | ||
this.logWriter.error({ | ||
err, | ||
module: 'Client', | ||
message: 'Error while processing the ResultSet.', | ||
args: { | ||
session_id: this.sessionId, | ||
query, | ||
query_id, | ||
}, | ||
}); | ||
}); | ||
} | ||
@@ -85,5 +96,7 @@ /** | ||
async command(params) { | ||
const { stream, query_id, summary } = await this.exec(params); | ||
await this.closeStream(stream); | ||
return { query_id, summary }; | ||
const query = removeTrailingSemi(params.query.trim()); | ||
return await this.connection.command({ | ||
query, | ||
...this.withClientQueryParams(params), | ||
}); | ||
} | ||
@@ -90,0 +103,0 @@ /** |
@@ -80,3 +80,3 @@ import type { InsertValues } from './client'; | ||
export type MakeConnection<Stream, Config = BaseClickHouseClientConfigOptionsWithURL> = (config: Config, params: ConnectionParams) => Connection<Stream>; | ||
export type MakeResultSet<Stream> = <Format extends DataFormat, ResultSet extends BaseResultSet<Stream, Format>>(stream: Stream, format: Format, query_id: string) => ResultSet; | ||
export type MakeResultSet<Stream> = <Format extends DataFormat, ResultSet extends BaseResultSet<Stream, Format>>(stream: Stream, format: Format, query_id: string, log_error: (err: Error) => void) => ResultSet; | ||
export interface ValuesEncoder<Stream> { | ||
@@ -95,3 +95,2 @@ validateInsertValues<T = unknown>(values: InsertValues<Stream, T>, format: DataFormat): void; | ||
} | ||
export type CloseStream<Stream> = (stream: Stream) => Promise<void>; | ||
/** | ||
@@ -115,3 +114,2 @@ * An implementation might have extra config parameters that we can parse from the connection URL. | ||
values_encoder: ValuesEncoder<Stream>; | ||
close_stream: CloseStream<Stream>; | ||
handle_specific_url_params?: HandleImplSpecificURLParams; | ||
@@ -118,0 +116,0 @@ }; |
@@ -44,2 +44,3 @@ import type { WithClickHouseSummary } from './clickhouse_types'; | ||
export type ConnExecResult<Stream> = ConnQueryResult<Stream> & WithClickHouseSummary; | ||
export type ConnCommandResult = ConnBaseResult & WithClickHouseSummary; | ||
export type ConnPingResult = { | ||
@@ -51,3 +52,3 @@ success: true; | ||
}; | ||
export type ConnOperation = 'Ping' | 'Query' | 'Insert' | 'Exec'; | ||
export type ConnOperation = 'Ping' | 'Query' | 'Insert' | 'Exec' | 'Command'; | ||
export interface Connection<Stream> { | ||
@@ -57,4 +58,5 @@ ping(): Promise<ConnPingResult>; | ||
query(params: ConnBaseQueryParams): Promise<ConnQueryResult<Stream>>; | ||
insert(params: ConnInsertParams<Stream>): Promise<ConnInsertResult>; | ||
exec(params: ConnBaseQueryParams): Promise<ConnExecResult<Stream>>; | ||
insert(params: ConnInsertParams<Stream>): Promise<ConnInsertResult>; | ||
command(params: ConnBaseQueryParams): Promise<ConnCommandResult>; | ||
} |
@@ -16,4 +16,4 @@ /** Should be re-exported by the implementation */ | ||
export { parseError } from './error'; | ||
export type { CompressionSettings, Connection, ConnectionParams, ConnInsertResult, ConnExecResult, ConnQueryResult, ConnBaseQueryParams, ConnBaseResult, ConnInsertParams, ConnPingResult, ConnOperation, } from './connection'; | ||
export type { CompressionSettings, Connection, ConnectionParams, ConnInsertResult, ConnExecResult, ConnQueryResult, ConnBaseQueryParams, ConnBaseResult, ConnInsertParams, ConnPingResult, ConnCommandResult, ConnOperation, } from './connection'; | ||
export type { QueryParamsWithFormat } from './client'; | ||
export type { IsSame } from './ts_utils'; |
@@ -10,3 +10,3 @@ "use strict"; | ||
if (args) { | ||
params.push('Arguments:', args); | ||
params.push('\nArguments:', args); | ||
} | ||
@@ -20,3 +20,3 @@ console.debug(...params); | ||
if (args) { | ||
params.push('Arguments:', args); | ||
params.push('\nArguments:', args); | ||
} | ||
@@ -30,3 +30,3 @@ console.debug(...params); | ||
if (args) { | ||
params.push('Arguments:', args); | ||
params.push('\nArguments:', args); | ||
} | ||
@@ -40,6 +40,6 @@ console.info(...params); | ||
if (args) { | ||
params.push('Arguments:', args); | ||
params.push('\nArguments:', args); | ||
} | ||
if (err) { | ||
params.push('Caused by:', err); | ||
params.push('\nCaused by:', err); | ||
} | ||
@@ -53,5 +53,5 @@ console.warn(...params); | ||
if (args) { | ||
params.push('Arguments:', args); | ||
params.push('\nArguments:', args); | ||
} | ||
params.push('Caused by:', err); | ||
params.push('\nCaused by:', err); | ||
console.error(...params); | ||
@@ -58,0 +58,0 @@ } |
@@ -1,2 +0,2 @@ | ||
declare const _default: "1.0.1"; | ||
declare const _default: "1.0.2"; | ||
export default _default; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = '1.0.1'; | ||
exports.default = '1.0.2'; | ||
//# sourceMappingURL=version.js.map |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://clickhouse.com", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"license": "Apache-2.0", | ||
@@ -8,0 +8,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
269012
3619