Skip to content

integrations(hypequery): import substituteParameters instead of copying it#65

Merged
ShawnChen-Sirius merged 1 commit into
chdb-io:mainfrom
ShawnChen-Sirius:feat/hypequery-import-utils
Jul 2, 2026
Merged

integrations(hypequery): import substituteParameters instead of copying it#65
ShawnChen-Sirius merged 1 commit into
chdb-io:mainfrom
ShawnChen-Sirius:feat/hypequery-import-utils

Conversation

@ShawnChen-Sirius

@ShawnChen-Sirius ShawnChen-Sirius commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Follow-up cleanup now that both halves have landed:

So the copy can go.

Change

  • import { substituteParameters } from '@hypequery/clickhouse' and delete the duplicated substituteParameters/escapeValue helpers (~40 lines).
  • Bump the @hypequery/clickhouse optional peer to >=2.1.2 (first version with the exports) and the devDependency to ^2.1.2.

Why it's safe

  • Anyone using chdb/hypequery is by definition using hypequery, so @hypequery/clickhouse is already installed — the runtime import adds no real dependency, and it stays an optional peer.
  • Using hypequery's own substituteParameters guarantees the SQL the adapter renders stays byte-identical to hypequery's built-in HTTP adapter, instead of relying on a copy that can drift.

Verification

  • Installed @hypequery/clickhouse@2.1.2 and confirmed both substituteParameters and escapeValue are exported (runtime + .d.ts).
  • test/v3/integrations/hypequery.test.ts passes 4/4 against the real imported helper (the run logs show hypequery itself engaged).

🤖 Generated with Claude Code

Note

Replace local substituteParameters implementation with import from @hypequery/clickhouse

Removes the local substituteParameters and escapeValue helpers from hypequery.mjs and delegates parameter substitution to the upstream library instead. Bumps the @hypequery/clickhouse dependency from ^2.1.1 to ^2.1.2 and tightens the peer dependency range to >=2.1.2 to match.

Macroscope summarized da149e3.

…ng it

The chdb/hypequery adapter shipped a byte-for-byte copy of hypequery's
substituteParameters/escapeValue because those helpers were not exported
when the adapter landed. @hypequery/clickhouse 2.1.2 now exports them, so
import substituteParameters directly and delete the copy.

- import { substituteParameters } from '@hypequery/clickhouse'
- drop the duplicated substituteParameters/escapeValue helpers (~40 lines)
- bump the @hypequery/clickhouse optional peer to >=2.1.2 (first version
  with the exports) and the devDependency to ^2.1.2

This removes escaping logic that could drift from hypequery's own and keeps
the generated SQL byte-identical to hypequery's built-in HTTP adapter.
Anyone using chdb/hypequery necessarily has @hypequery/clickhouse installed,
so the runtime import adds no real dependency; it stays an optional peer.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ShawnChen-Sirius ShawnChen-Sirius requested a review from Copilot July 1, 2026 23:31
@ShawnChen-Sirius

Copy link
Copy Markdown
Contributor Author

@chibugai, review it

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR cleans up the chdb/hypequery integration by removing a previously inlined copy of hypequery’s parameter substitution/escaping logic and instead delegating to the upstream @hypequery/clickhouse implementation (now exported as of 2.1.2).

Changes:

  • Bump @hypequery/clickhouse devDependency to ^2.1.2 and peer dependency to >=2.1.2.
  • Replace the local substituteParameters/escapeValue helpers in integrations/hypequery.mjs with an import of substituteParameters from @hypequery/clickhouse.
  • Update the lockfile accordingly.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
package.json Updates @hypequery/clickhouse dev + peer dependency versions to require the first release that exports substituteParameters.
package-lock.json Syncs lockfile with the dependency bump and updated peer dependency metadata.
integrations/hypequery.mjs Switches from duplicated helper code to using upstream substituteParameters for byte-identical SQL rendering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread integrations/hypequery.mjs
@chibugai

chibugai commented Jul 1, 2026

Copy link
Copy Markdown

Reviewed — OCR (opus-4-8) deep pass + a manual read of the diff. Small, well-scoped cleanup; LGTM with one judgment call to make consciously.

Clean:

  • Local substituteParameters/escapeValue removed with no dangling references; the imported substituteParameters is wired consistently through query(), stream(), and render() (each substitutes once from raw params — no double-substitution).
  • Peer bump to >=2.1.2 matches the first version that exports the helpers, so the range is honest.
  • Since these helpers were originally copied verbatim from hypequery's core/utils.ts, importing them back is exactly what keeps the rendered SQL byte-identical — and the 4/4 hypequery.test.ts run backs that up.

One thing to weigh (already flagged by Copilot, so not re-posting inline): the new top-level import { substituteParameters } from '@hypequery/clickhouse' turns this previously dependency-light module into one that throws ERR_MODULE_NOT_FOUND at import time if the optional peer is absent — before chdbAdapter() is ever called. Your rationale (anyone importing this adapter already has hypequery installed) holds for normal usage; the edge cases are tooling that eagerly imports every subpath export, or dependency scanners. A lazy/guarded import with a targeted error (per Copilot's suggestion) would preserve the optional-peer contract — non-blocking, your call.

No correctness or safety issues in the diff.

@ShawnChen-Sirius ShawnChen-Sirius merged commit bd468cb into chdb-io:main Jul 2, 2026
18 checks passed
ShawnChen-Sirius added a commit that referenced this pull request Jul 7, 2026
…w integrations

Additive minor release on top of 3.1.0 (2026-06-24). No breaking changes;
existing 3.1.0 APIs continue to work unchanged. libchdb bits are unchanged
(chdb-core v26.5.1-rc.1 packaged as @chdb/lib-* 26.5.2 — no republish
needed, the subpackage-matrix job will idempotent-skip).

## What's new

### Layer 3 fluent query builder SDK (#55, #59)

First-class typed fluent query API — Kysely-/Drizzle-style:

    const db = connect({ session })
    const rows = await db
      .from('users')
      .where(r => r.age.gt(18))
      .select('id', 'name')
      .execute()

- `src/layer3/{builder,execute,compile,dialect,introspection,connect,types,codegen}/`
- `chdb-gen-types` CLI — generates row types from a schema (Drizzle /
  Prisma / raw SQL sources)
- `.stream()` terminal with server-side parameter binding
- Arrow C Data Interface support: register JS columnar data as
  `arrowstream()` tables
- 12 new test files under `test/v3/layer3/`

### Cross-language agent-tool contract + 2 framework adapters (#61, #66)

- `chdb/ai-sdk` — Vercel AI SDK tools (`generateText`/`streamText`)
- `chdb/mastra` — Mastra tools + `ChDBVector` (HNSW RAG store) + `ChDBStore`
- Both are thin wrappers over `ChDBTool.call()` from `integrations/agents/`,
  which implements the cross-language contract vendored from `chdb-io/chdb`
  (`chdb/agents/CONTRACT.md`, chdb-io/chdb#597).
- 7 canonical tools: `run_select_query` / `list_databases` / `list_tables` /
  `describe_table` / `get_sample_data` / `list_functions` / `attach_file`
- 5 pillars enforced: engine-level readonly=2 (P1), value-vs-identifier
  separation (P2), truncation flag (P3), error envelope for model
  self-correction (P4), resource/source controls (P5)
- Behavior verified against the shared `conformance/cases.jsonl` fixture

### `chdb/hypequery` DatabaseAdapter (#63, #65)

Lets `@hypequery/clickhouse` query builder run on embedded chDB instead
of a remote ClickHouse server. Uses hypequery's own `substituteParameters`
(imported, not copied) so rendered SQL stays byte-identical to hypequery's
built-in HTTP adapter.

### `chdb/connection` stabilization for @clickhouse/client 1.23.0

- `peerDependency: "@clickhouse/client: >=1.23.0"` (optional) — old client
  triggers a clear npm warning instead of a runtime TS error
- Parity runner switched to track `ClickHouse/clickhouse-js` release tag
  `client-1.23.0` (per the sync-policy table; #52 shipped the initial hook)
- Runner auto-detects upstream Vitest layout (pre-/post-clickhouse-js#931)
- Runner re-synced when clickhouse-js reorganized into a monorepo (#62)

### AI-discovery docs (#60)

- Top-level `AGENTS.md` + `llms-full.txt`
- Per-subpath `AGENTS.md` (`src/layer3/`, `src/connection/`, etc.)
- All packaged in `files` so agents crawling the installed tarball find them

## Fixes / infrastructure

- Bind `null` / `undefined` query params as SQL `\N` (contributor
  @dfrankland, #68) — matches `@clickhouse/client` behavior
- `close()`-mid-flight engine abort + ResultSet teardown race (#56)
- `ChDBVector` HNSW granularity / filter binding / dimension guard (#61)
- Release workflow: publish → `unverified` dist-tag → clean-install verify
  matrix → promote to `latest` (#64). A broken release now never reaches
  `latest` users.
- CI: cache deps + harden npm registry fetch against transient resets

## User-facing installation matrix

```
npm install chdb                                    # base + Layer 3 SDK
npm install chdb @clickhouse/client                 # + chdb/connection
npm install chdb @hypequery/clickhouse              # + chdb/hypequery
npm install chdb ai zod                             # + chdb/ai-sdk
npm install chdb @mastra/core zod                   # + chdb/mastra
```

Native libchdb: chdb-core v26.5.1-rc.1 (packaged as @chdb/lib-* 26.5.2),
unchanged from 3.1.0.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
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.

3 participants