Socket
Socket
Sign inDemoInstall

@clickhouse/client-common

Package Overview
Dependencies
Maintainers
4
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clickhouse/client-common - npm Package Compare versions

Comparing version 0.2.7 to 0.2.8

23

dist/client.d.ts

@@ -1,2 +0,2 @@

import type { ClickHouseLogLevel, ClickHouseSettings, Connection, ConnectionParams, ConnInsertResult, Logger, WithClickHouseSummary, ConnExecResult } from '@clickhouse/client-common';
import type { ClickHouseLogLevel, ClickHouseSettings, Connection, ConnectionParams, ConnExecResult, ConnInsertResult, Logger, WithClickHouseSummary } from '@clickhouse/client-common';
import { type DataFormat } from '@clickhouse/client-common';

@@ -95,2 +95,7 @@ import type { InputJSON, InputJSONObjectEachRow } from './clickhouse_types';

export type InsertValues<Stream, T = unknown> = ReadonlyArray<T> | Stream | InputJSON<T> | InputJSONObjectEachRow<T>;
type NonEmptyArray<T> = [T, ...T[]];
/** {@link except} field contains a non-empty list of columns to exclude when generating `(* EXCEPT (...))` clause */
export interface InsertColumnsExcept {
except: NonEmptyArray<string>;
}
export interface InsertParams<Stream = unknown, T = unknown> extends BaseQueryParams {

@@ -101,4 +106,17 @@ /** Name of a table to insert into. */

values: InsertValues<Stream, T>;
/** Format of the dataset to insert. */
/** Format of the dataset to insert. Default: `JSONCompactEachRow` */
format?: DataFormat;
/**
* Allows to specify which columns the data will be inserted into.
* Accepts either an array of strings (column names) or an object of {@link InsertColumnsExcept} type.
* Examples of generated queries:
*
* - An array such as `['a', 'b']` will generate: `INSERT INTO table (a, b) FORMAT DataFormat`
* - An object such as `{ except: ['a', 'b'] }` will generate: `INSERT INTO table (* EXCEPT (a, b)) FORMAT DataFormat`
*
* By default, the data is inserted into all columns of the {@link InsertParams.table},
* and the generated statement will be: `INSERT INTO table FORMAT DataFormat`.
*
* See also: https://clickhouse.com/docs/en/sql-reference/statements/insert-into */
columns?: NonEmptyArray<string> | InsertColumnsExcept;
}

@@ -155,1 +173,2 @@ export declare class ClickHouseClient<Stream = unknown> {

}
export {};

@@ -112,3 +112,3 @@ "use strict";

this.valuesEncoder.validateInsertValues(params.values, format);
const query = `INSERT INTO ${params.table.trim()} FORMAT ${format}`;
const query = getInsertQuery(params, format);
return await this.connection.insert({

@@ -187,2 +187,22 @@ query,

}
function isInsertColumnsExcept(obj) {
return (obj !== undefined &&
obj !== null &&
typeof obj === 'object' &&
// Avoiding ESLint no-prototype-builtins error
Object.prototype.hasOwnProperty.call(obj, 'except'));
}
function getInsertQuery(params, format) {
let columnsPart = '';
if (params.columns !== undefined) {
if (Array.isArray(params.columns) && params.columns.length > 0) {
columnsPart = ` (${params.columns.join(', ')})`;
}
else if (isInsertColumnsExcept(params.columns) &&
params.columns.except.length > 0) {
columnsPart = ` (* EXCEPT (${params.columns.except.join(', ')}))`;
}
}
return `INSERT INTO ${params.table.trim()}${columnsPart} FORMAT ${format}`;
}
//# sourceMappingURL=client.js.map

2

dist/version.d.ts

@@ -1,2 +0,2 @@

declare const _default: "0.2.7";
declare const _default: "0.2.8";
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = '0.2.7';
exports.default = '0.2.8';
//# sourceMappingURL=version.js.map

@@ -5,3 +5,3 @@ {

"homepage": "https://clickhouse.com",
"version": "0.2.7",
"version": "0.2.8",
"license": "Apache-2.0",

@@ -8,0 +8,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc