ClickHouse / clickhouse-js

Official JS client for ClickHouse DB
https://clickhouse.com
Apache License 2.0
189 stars 22 forks source link

[client-common] Missing `rows_before_limit_at_least` property in `ResponseJSON<T>` type #267

Closed 0237h closed 2 months ago

0237h commented 2 months ago

Describe the bug

It seems that the property rows_before_limit_at_least (described here in the docs) is missing from the ResponseJSON<T> type for the client-common library.

This leads to a property doesn't exists error in Typescript although the property can be accessed at runtime.

Current definition

packages/client-common/src/clickhouse_types.ts

export interface ResponseJSON<T = unknown> {
    data: Array<T>;
    query_id?: string;
    totals?: Record<string, number>;
    extremes?: Record<string, any>;
    meta?: Array<{
        name: string;
        type: string;
    }>;
    statistics?: {
        elapsed: number;
        rows_read: number;
        bytes_read: number;
    };
    rows?: number;
}

Expected definition

export interface ResponseJSON<T = unknown> {
    data: Array<T>;
    query_id?: string;
    totals?: Record<string, number>;
    extremes?: Record<string, any>;
    meta?: Array<{
        name: string;
        type: string;
    }>;
    statistics?: {
        elapsed: number;
        rows_read: number;
        bytes_read: number;
    };
    rows?: number;
    rows_before_limit_at_least?: number;
}

Code example

const response = await client.query({ query, query_params, format: "JSON" });
const data: ResponseJSON<T> = await response.json();

console.log({
    statistics: data.statistics,
    rows: data.rows,
    rows_before_limit_at_least: data.rows_before_limit_at_least // property doesn't exists
});

Configuration

Environment

slvrtrn commented 2 months ago

Thanks for the report. Do you want to open a PR?

0237h commented 2 months ago

Thanks for the report. Do you want to open a PR?

Sure can do :+1:

slvrtrn commented 2 months ago

The fix will be released as 1.0.2 on Monday.